[swift-evolution] Immutable Structures
brent at architechies.com
Fri Dec 25 18:16:13 CST 2015
> However I could probably still agree with you if mutating was also used in classes. What's the point of having it only on structures?
In a regular method, `self` is a regular (constant) parameter, but in a `mutating` method, `self` is `inout` so that it can be mutated and those mutations will reach the caller's copy of the instance. There's no need for an `inout` `self` on reference types, because the mutations are performed on the shared instance which both the caller and callee have a reference to, so `mutating` only really makes sense for value types.
More information about the swift-evolution