From: Tanner Burson Date: 2006-11-03T06:23:27+09:00 Subject: Re: str1 = str2 is not a copy?!? ------=_Part_13139_6539950.1162502591114 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 11/2/06, Gavin Kistner wrote: > > From: Joe Ruby MUDCRAP-CE > [snip] > > WHY is var line getting changed by operations on var base_name? Isn't > > 'base_name = line' supposed to create a copy? '=' in this > > case seems to be acting like an alias or something. > > Variables point to objects, they do not "hold" or "contain" them. > > What you are suggesting is that: > me = Person.new > would create a new Person object, and then duplicate it before assigning > to 'me', or that: > my_really_long_array_name = [ 1, 2, 3 ] > short_name = my_really_long_array_name > would result in two different copies of the array. > > That's the opposite of how it works :) But is oddly enough almost exactly how it works in PHP. And thus one of the major battles PHP has had between versions has been about the semantices of reference, and pass/call by reference. I'm GLAD Ruby functions this way, as it removes a lot of complexity dealing with references. -- ===Tanner Burson=== tanner.burson@gmail.com http://tannerburson.com <---Might even work one day... ------=_Part_13139_6539950.1162502591114--