I am confused about structure vs class. I have seen this example According to this example structure-vs-class According to link may be code output is 15,15,15,20
BUT code output is because Structure is not changed but when I have run code on Xcode it returns me 15,15,20,20
class objectmanagement
{
public var x : Int = 10;
func display()
{
print("\(x)")
}
}
struct StuctManagement{
var obj = objectmanagement()
}
let SA = StuctManagement()
SA.obj.x = 15
var SB = StuctManagement()
SB.obj = SA.obj
SA.obj.display()
SB.obj.display()
SB.obj.x = 20
SA.obj.display()
SB.obj.display()
I am confused please help me to understand this output this is same as a class output