Values & References11 / 16
Up next

A struct arg is a copy

struct Point { var x: Int }
// the parameter is a copy; mutating it stays local
func moveLocally(_ p: Point) {
    var p = p
    p.x = 999
    print("inside: \(p.x)")
}
let p = Point(x: 1)
moveLocally(p)
print("outside: \(p.x)")
What you're solving

the callee cannot change the caller's struct