From: Simon ARNAUD Date: 2002-02-26T10:24:48+09:00 Subject: Re: Assignment Rules Yes, you understand it well. Wrinting var1 = "qweqwe" is equivalent to var1 = String.new "qweqwe" if you want to replace the string in var1, then you should use something like this: var1.replace "qweqwe" Simon ARNAUD aka Maz On Tue, 26 Feb 2002 00:53:01 +0100, Sean O'Dell wrote: > 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