Michael Long
Aug 24, 2021

--

I could rephrase the sentence begining with (As a general rule...), but in reality the compiler's behind-the-scenes optimizations are irrelevent from a behavioral standpoint.

Structs built from value types have value semantics, where mutating a copy of A doesn't affect the orignal A, and that's the behavior the Swift compiler guarantees.

And since that's what the Swift compiler guarantees, we can depend on that behavior when dealing with our mutable objects (structs).

--

--

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

No responses yet