"Thomas Hurst" <tom.hurst / clara.net> wrote in message > * Sean O'Dell
(sean / celsoft.com) wrote:
>
> > var1 = "asdasd"
> > var2 = var1
> > var1 = "qweqwe"
> > print("VAR2: #{var2}\n")
>
> No, you're thinking along the wrong lines: var2 does not point to var1,
> var2 points to the object that is pointed to by var1 at the time of the
> assignment.  You then change the object var1 points to (another string),
> but var2 still points to the original object.

So, when I wrote:

var1 = "qweqwe" I must have been creating a new string object, right?

This is very wierd to me.  When I say objectvar = "asdasd", I sort of expect
objectvar to be an object that receives the string.

So, when I say

var1 = 10
var2 = var1
var1 = 20

....what's happening is var1 points to the object created by the expression
'10', then var2 points to the same object, then var1 is changed to point to
a new object created by the expression '20', right?

So, what's the rule?  Assignment only changes which object the left operand
points to, but the right can either be an existing object, an object created
explicitly using 'new' or something similar, or implicitly by expressing a
string or number?

    Sean