Values & References13 / 16
Up next

Mutating methods

struct Counter {
    var value = 0
    // mutating is required to change a struct's own properties
    mutating func bump() {
        value += 1
    }
}
var c = Counter()
c.bump()
c.bump()
print(c.value)
What you're solving

a struct method that changes self