From: 7stud -- Date: 2009-09-11T10:16:37+09:00 Subject: Re: populating a hash from an array using inject 7stud -- wrote: > h = Hash.new([]) > > h["A"] = h["A"] << 10 #==>[10] > > h["B"] = h["B"] << 20 #==>[20] > > Look what happens: > > > p h > > {"A"=>[10, 20], "B"=>[10, 20]} > Yep, ruby hands you a reference to the same array over and over again...when you try to access non-existent keys. -- Posted via http://www.ruby-forum.com/.