From: Harry Ohlsen Date: 2004-04-07T15:31:50+09:00 Subject: Re: deciding between ruby and python gabriele renzi wrote: >>... it yields pairs >>for you to do what you want with. > > > yes, after it constructed one big array:) Yes, he's creating a hash (not an array), but that's presumably just because he grabbed the code from a real application, where he wants to be able to re-use the values. He could just as easily have written the following, which only holds two values at any given time, but can iterate over as many as you like ... class Fib def initialize(fn = 1, fn_1 = 1) @fn = 1 @fn_1 = 1 end def each(limit = 1000, &block) limit.times do yield @fn @fn, @fn_1 = @fn_1, (@fn + @fn_1) end end end fib = Fib.new for i in fib puts i end