Examples · learn/11-values · 173 of 339
inout-method
tin run examples/learn/11-values/inout-method.tintype Counter = { count: int }
// A method whose first parameter is inout changes the value it is called on.
fn Counter.bump(c: inout Counter) {
c.count += 1
}
fn main() {
var clicks = Counter { count: 0 }
clicks.bump() // a method call on a var needs no &
clicks.bump()
print(clicks.count)
}