It is neither pass-by-value or pass-by-reference - it is call-by-object. See this, by Fredrik Lundh:
http://effbot.org/zone/call-by-object.htm
Here is a significant quote:
"...variables [names] are not objects; they cannot be denoted by other variables or referred to by objects."
In your example, when the Change
method is called--a namespace is created for it; and var
becomes a name, within that namespace, for the string object 'Original'
. That object then has a name in two namespaces. Next, var = 'Changed'
binds var
to a new string object, and thus the method's namespace forgets about 'Original'
. Finally, that namespace is forgotten, and the string 'Changed'
along with it.