Swift Value Semantics
Array(repeating:) Looks Like It Makes Five Objects. It Makes One, Five Times.
Array(repeating:count:) copies its value into every slot — which is exactly why it silently breaks the moment that value is a class instance. Here's the reference-sharing bug and how to actually get five independent objects.
5 min read
Swift Value Semantics
Your Struct Looks Like It Copies When You Assign It. If It Wraps a Class, It Might Just Be Sharing.
Array gets copy-on-write for free because it checks isKnownUniquelyReferenced before every mutation. Build your own struct around a class-based buffer without that check, and 'independent copies' quietly become one shared object.
7 min read