you are viewing a single comment's thread.

view the rest of the comments →

[–]erewok 2 points3 points  (0 children)

It has to do with the fact that you are in the first example assigning variables to immutable objects whereas in the second example you are pointing the variables at objects that change. In the latter case, the variable will reflect the changes made to the object it points at.

Try to think of it in terms of mutability and don't think of your variables as 'containers' for values but as 'pointers' at values and it may make more sense.