They indispensible. Once you understand the other iterators, inject  
becomes natural.

Try doing some form of aggregation without using inject. Haha fun.

# example program to illustrate inject
num_ary = [10,37,27,398,273,28]

# summing without inject:
without_inject_sum = 0
num_ary.each{|num| without_inject_sum += num}

# summing with inject
with_inject_sum = num_ary.inject{|sum, num| sum + num}

Julian

On 31/03/2008, at 8:41 AM, Thomas Wieczorek wrote:

> On Sun, Mar 30, 2008 at 8:27 AM, 7stud -- <bbxx789_05ss / yahoo.com>  
> wrote:
>> Oh, yeah:
>>
>> $ ruby -v
>> ruby 1.8.2 (2004-12-25) [universal-darwin8.0]
>>
>>
>> By the way, using inject() is inefficient--not to mention confusing.
>> You might as well pretend it doesn't exist.
>>
>
> I absolutely can't agree with that. map and inject are two beautiful
> functions which should be known for the average Ruby programmer imo.
> Instead of using some loops, you can easily use map to apply a
> function on each member. I like them.
>