Say, for example, that I set x = [1,2,3]
, and then set temp = x
.
Then, because x
and temp
are referring to the same value, if we do temp.reverse()
, both temp
and x
are reversed.
Why, then, if we set x = [1,2,3]
and set temp = x
, and then temp = [7,8,9]
, is x
not still equal to temp
(x = [1,2,3]
and temp = [7,8,9]
)? We've still modified temp
, but unlike in the above example, the alias does not stick. Why is this?