From: "David A. Black" Date: 2008-11-27T18:32:08+09:00 Subject: Re: creating a dynamic hash Hi -- On Thu, 27 Nov 2008, Heesob Park wrote: > 2008/11/27 Sijo Kg : >> Hi >> I could solve the problem like >> hashes = [] >> for i in 0..elapsedtime.length-1 >> hashes[i] = {:bevel => 'bevel1',:value => 5} >> end >> return hashes >> > You can do it like this > > hashes = [{:bevel => 'bevel1',:value => 5}] * (elapsedtime.length-1) That's not the same, because you get the same hash n times, instead of n hashes once each. hashes = [{:x => 1, :y => 2}] * 3 hashes[0].delete(:x) p hashes # [{:y=>2}, {:y=>2}, {:y=>2}] David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL Advancing with Rails January 19-22 Fort Lauderdale, FL * * Co-taught with Patrick Ewing! See http://www.rubypal.com for details and updates!