From: Adam Shelly Date: 2008-08-29T02:07:40+09:00 Subject: Re: Dumb "array of arrays" question On 8/28/08, Thomas B. wrote: > Hello Richard, > > RichardOnRails wrote: > > More importantly, according to my tests below, dup'ing an array does > > NOT make a new array. It returns the (address of/pointer to) the same > > old array. > > dup'ing an array DOES make a new array, only the new array looks like > the old one, because Array#inspect doesn't return the address of the > array so you cannot see if it is exactly the same instance or not. > > 3: [#]; #; Array > > 4: [#]; #; Array > > The [#]'s here are in fact different objects, only > they look the same. > You can prove they are different objects this way: code: a = [Object.new]; ad = a.dup puts a.inspect+ ", #{a.object_id}" puts ad.inspect+ ", #{ad.object_id}" output: [#], 21107090 [#], 21107070 -Adam