> If you run the code you'll see 1 2 3 4 3 printed instead of 5.
I'm really confused, as this behaviour appears to be completely obvious to me.
I'm really confused, as this behaviour appears to be completely obvious to me.
Of course in a real life program, it may be lost in other code logic and, most importantly, the function performing the clone may not be so explicit about it (e.g. an "update" function that returns a different copy of the object).