I'm curious, how to best explain why when you do:
and you do this:
why does P's (as an obj) also gets R's values:
(the numbered list represent each line)
It says: [3, 4]
Just performs reference assignment. It doesn't clone or copy the object(s). This is the same behavior in a lot of popular languages, including C/C++, Java and Ruby.
You can think of it as simply declaring another 'name' (or reference) for the object 'held' by the current variable named
Note that primitive variables behave differently from variables containing references to objects, which is likely the source of your confusion. In Ruby, for example: