From: Suraj Kurapati Date: 2009-03-31T08:18:47+09:00 Subject: Re: Is there an idiom for mass-populating Hash keys? Suraj Kurapati wrote: > consider this "dynamic programming" based Fibonacci sequence implementation: > > fib = Hash.new {|h,k| k < 2 ? 1 : h[k-1] + h[k-2] } Whoops, I forgot to store the computed value in the hash! fib = Hash.new {|h,k| h[k] = k < 2 ? 1 : h[k-1] + h[k-2] } Now it should work. Sigh :-) -- Posted via http://www.ruby-forum.com/.