Sean O'Halpin <sean.ohalpin / gmail.com> wrote:
> > sum = enum.accumulate(0, :+) {|x| f(x)}
> 
> How about
> 
> module Enumerable
> 
>   def accumulate(initial, method, &block)

<snip>

> 
> 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