From: Sean O'Halpin Date: 2012-08-13T08:38:19+09:00 Subject: Re: What should I use instead of Generator in 1.9? On Sun, Aug 12, 2012 at 11:25 PM, Andrew S. wrote: > Thanks!! How do I implement the equivalent of generator's .next? method > in order to avoid the following... > > irb(main):001:0> @foo = (1..10).each > => # > irb(main):002:0> while true > irb(main):003:1> puts @foo.next > irb(main):004:1> end [snip] > StopIteration: iteration reached an end Well, you could just do this: begin while true puts @foo.next end rescue StopIteration end or even better (because loop catches the StopIteration for you): loop do puts @foo.next end Regards, Sean