let myclassInstance1 = myclass()
let myclassInstance2 = myclassInstance1
myclassInstance1.prop1 = 2
myclassInstance2.prop1 = 3
This code is supposed to throw error as I am altering the constant.
But it's not happening.
How come?
let myclassInstance1 = myclass()
let myclassInstance2 = myclassInstance1
myclassInstance1.prop1 = 2
myclassInstance2.prop1 = 3
This code is supposed to throw error as I am altering the constant.
But it's not happening.
How come?
The class instance is not constant. Just the reference is.
This means you cannot do this:
let myClassInstance = MyClass()
myClassInstance = MyClass()