I'm learning Swift language now a days.
In Apple's documentation I saw a example for extension like:
extension Int: ExampleProtocol {
var simpleDescription: String {
return "The number \(self)"
}
mutating func adjust() {
self += 42
}
}
7.simpleDescription
So I just called the adjust()
like:
7.adjust()
It throws an error:
Immutable value of type `Int` only has mutating members named adjust.
I'm not sure what causes the error ? Can anybody help me to understand the issue ?