← Back to context

Comment by sumuyuda

6 days ago

> when every data structure is COPIED on every function call

Swift structs use copy on write, so they aren’t actually copied on every function call.

They are, as far as "Have one source of truth" is concerned. That is what parent is talking about.

They don’t, by default. That’s something you have to implement yourself.

It’s a common misconception that comes from the standard library data structures, which almost all do implement CoW