What is the output?
class Box {
var value: Int
init(_ v: Int) { value = v }
}
let a = Box(5)
let b = a
b.value = 12
print(a.value)
print(b.value)
Try it in the online Swift Playground →
[spoiler title="Solution"]
Answer:
12 12
Explanation:
Classes are reference types, so a and b share the same instance.
[/spoiler]