From: "David A. Black" Date: 2008-11-27T18:34:33+09:00 Subject: Re: creating a dynamic hash Hi -- On Thu, 27 Nov 2008, Sijo Kg wrote: > Hi > I could solve the problem like > hashes = [] > for i in 0..elapsedtime.length-1 > hashes[i] = {:bevel => 'bevel1',:value => 5} > end > return hashes Let Ruby do the work :-) hashes = Array.new(elapsedtime.length-1) { {:bevel => 'bevel1', :value => 5 } } That gives you an array of the right length, where each element is initialized by running the code block, which gives you a new hash each time. 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!