From: Logan Capaldo Date: 2006-08-31T02:43:29+09:00 Subject: Re: [RCR] Array.step On Aug 30, 2006, at 1:12 PM, ara.t.howard@noaa.gov wrote: > > > > harp:~ > cat a.rb > class Array > def self.step i, *a, &b > j, s, ignored = *a > i, j = 0, i if j.nil? > s ||= (j < i ? -1 : 1) > list = new > i.step(j,s){|k| list << k} > list.map! &b if b > list > end > end > require 'enumerator' class Array def self.step(i, *a, &block) b = block || lambda { |x| x } i.to_enum(:step, *a).map(&b) end end