Leslie Viljoen wrote:
> On 5/21/06, Jim Weirich <jim / weirichhouse.org> wrote:
>> Jeff Pritchard wrote:
>> > As for Inject, nobody has come up with a wording that makes any sense to
>> > me yet.  Does Inject have any aliases/synonyms?
>>
>> How I remember:  Inject takes a binary operation (e.g. +) and injects it
>> between each element of a list.
>>
>>    [1,2,3].inject { |a,b| a+b }  => 1+2+3
> 
> Awesome! That really helps me!


Seems like "sum" would have been a better name.

Also

[1,2,3].each {|a| b += a}

is easier to read ...for me.

-- 
Posted via http://www.ruby-forum.com/.