From: matt@... (matt neuburg) Date: 2006-11-03T01:15:16+09:00 Subject: Re: variable pointer Wilson Bilkovich wrote: >On Thu, 2 Nov 2006 dblack@wobblini.net wrote: > > a = person.address > > person.address = Address.find(some_other_address) > > puts a # a has changed! > I must be missing something. Isn't this how virtually all Ruby code works? I had to do a double-take as well, so here's an example for the rest of us newbies trying to follow the discussion. Presume the following: address = Struct.new(:street).new("Main") address2 = Struct.new(:street).new("Oak") person = Struct.new(:address).new(address) Okay, now let's execute exactly the code being discussed: [1] a = person.address person.address = address2 p a # Main So assigning directly to person's address didn't change "a". OTOH: [2] a = person.address person.address.street = "Oak" puts a.street # => Oak So I think what's unexpected is that, in the RoR example, [1] behaves as if it had been [2]. m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Tiger - http://www.takecontrolbooks.com/tiger-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com