#54: Why mutating Exists in Swift
Structs and enums are value types, so methods that modify them must be marked with mutating.
struct Counter {
private(set) var value = 0
mutating func increment() {
value += 1
}
}
That keyword makes state changes explicit at the call site and in the type definition.
Classes do not need this because they already use reference semantics. For value types, mutating is one of the small details that keeps side effects visible.