From: Martin DeMello Date: 2005-09-18T00:51:35+09:00 Subject: Re: Math: sum and faculty Sean O'Halpin wrote: > > sum = enum.accumulate(0, :+) {|x| f(x)} > > How about > > module Enumerable > > def accumulate(initial, method, &block) > > It's worth getting to know inject however.A Definitely. OTOH, it's also worth stepping back every so often and seeing if you can "pretty up" your code. (Incidentally, a fun exercise to get familiar with inject is to try writing all of Enumerable in terms of inject rather than each.) martin