Values & References5 / 16
Up next

A class arg is shared

class Box { var n = 0 }
// the parameter references the caller's instance
func fill(_ b: Box) {
    b.n = 42
}
let box = Box()
fill(box)
print(box.n)
What you're solving

the callee can mutate the instance