From: Jeff Mitchell Date: 2004-04-25T09:23:52+09:00 Subject: Re: Propose Range.new(..., &succ) --- Kristof Bastiaensen wrote: > On Sun, 25 Apr 2004 02:20:03 +0900, Jeff Mitchell wrote: > > accum = [] > > 5.step(8, 0.5) { |x| > > accum << > > # stuff > > } > > accum.other_stuff > > > > ... > > Hi, > here is an alternative, using the incredible enum_for :-) > (doesn't work with ruby-1.6). > > require "enumerator" > 5.enum_for(:step, 8, 0.5).map { |x| #stuff }.other_stuff > Thanks, I never knew about that. Just another one of those neat features in the standard library which is pushed into obscurity due to having no documentation. __________________________________ Do you Yahoo!? Yahoo! Photos: High-quality 4x6 digital prints for 25� http://photos.yahoo.com/ph/print_splash