johannes87
(Johannes Bittner)
1
The Swift book on ARC says:
This strong reference cycle occurs because closures, like classes, are reference types . When you assign a closure to a property, you are assigning a reference to that closure.
I would have expected the last sentence to end with “to that property” instead of “closure”.
Why is it that, when I assign a closure to a property, I’m also assigning a reference to that closure? What reference is being assigned to that closure?
ole
(Ole Begemann)
2
The Swift book on ARC says:
… When you assign a closure to a property, you are assigning a reference to that closure.
I think a longer version of that sentence would say:
When you assign a closure to a property, you are assigning a reference to that closure to the property.
So your intuition is correct. No reference is being assigned to the closure. A reference to the closure is being assigned to the property.
4 Likes
I think you’re being confused by an ambiguous use of “to that”. An English language confusion rather than a Swift one.
Maybe this would be clearer: “When you assign a closure to a property, the property’s value is set to a reference to the closure.”
10 Likes
johannes87
(Johannes Bittner)
4
Thanks for clarification!