On May 4, 2006, at 4:54 PM, ara.t.howard / noaa.gov wrote: > On Fri, 5 May 2006, Logan Capaldo wrote: > >> You know you can do this with inject right? > > not on 1.6.8 - which is still the standard redhat-enterprise install. > > that code is years and years old anyhow ;-) > > -a > -- > be kind whenever possible... it is always possible. > - h.h. the 14th dali lama > No inject in 1.6.8? Gasp! % cat emergency_inject.rb module Enumerable unless instance_methods.include? "inject" def inject(*seed) first_item = false if seed.empty? first_item = true else seed = seed[0] end each do |x| if first_item seed = x first_item = false else seed = yield(seed, x) end end return seed end end end