1
Consider the following code Techo:
class Circle {
var radius: Double
init(radius: Double)
{
print("I'm initializing a new Circle instance with a radius value of \(radius).")
self.radius = radius
}
deinit {
print("I'm destroying the Circle instance with a radius value of \(radius).")
}
}
1 var circle3 = Circle(radius: 42)
2 var referenceToCircle3 = circle3
3 referenceToCircle3.radius
4 circle3 = Circle(radius: 84)
5 referenceToCircle3.radius
6 circle3.radius
Since it is about classes, the passage is by reference, correct? That is, how referenceToCircle3
is equal to circle3
, both will have the same address in memory, Tuesday always the same value stored there.
Then why referenceToCircle3
(line 5) remains at the same value even when the circle3
had its value changed (line 4)?