What does this print?
@propertyWrapper
struct Cap {
private var n = 0
var wrappedValue: Int {
get { n }
set { n = min(newValue, 9) }
}
}
struct Box { @Cap var v: Int }
var b = Box()
b.v = 12
print(b.v)
Try it in the online Swift Playground →
[spoiler title="Solution"]
Answer:
9
Explanation:
The wrapper caps assigned values at 9, so setting 12 stores 9.
[/spoiler]