From: "David A. Black" Date: 2005-05-07T02:30:12+09:00 Subject: Re: object reference handle (like perl's reference to scalar) Hi -- On Sat, 7 May 2005, Patrick Hurley wrote: > On 5/4/05, Eric Mahurin wrote: >> In ruby, is there a way to get a handle of an object reference? >> In perl, this is the \ operator: >> >> $x = 1; # \$x is a handle to change $x >> $a = [1,2,3]; # \$a->[1] is a handle to change an element in $a >> > > Not the "ruby way," but how about: > > a = [1, 2, 3] > b = a.object_id > c = ObjectSpace._id2ref(b) > c[1] = 7 > puts a => [1, 7, 3] How about: a = b = c = [1,2,3] c[1] = 7 p a # [1, 7, 3] :-) David -- David A. Black dblack@wobblini.net