Avatar
struct Foo { let value: Int func multipliedValue(by multiplier: Int) -> Int { self.value * multiplier } mutating func increment() { self = Foo(value: self.value + 1) } } func multipliedValue(_ self: Foo, by multiplier: Int) -> Int { self.value * multiplier } func increment(_ self: inout Foo) { self = Foo(value: self.value + 1) } var foo: Foo = .init(value: 0) //foo.increment() increment(&foo) print(foo.value) print(foo.multipliedValue(by: 3)) print(multipliedValue(foo, by: 3))
👍 3