2 ms·
More importantly, Swift's structs come close to full immutability. If you declare a struct instance with `let`, the compiler throws an error if you try mutating
by trevor-e 9y ago
More importantly, Swift's structs come close to full immutability. If you declare a struct instance with `let`, the compiler throws an error if you try mutating its properties. You also have to mark functions in the struct as mutating if they modify any property. The only case this isn't true (and why I said comes close) is if you modify a property of a reference type within a struct.