I don't see how this is an alternative for inject; it's just a
different need. You use map when you want to generate a new Enumerable
and inject when you want to generate a single value. The answer to the
question "how does one iterate over multiple collections in parallel?"
is just to use zip and the fact that assignment of an array to multiple
variables puts the values of the elements into the variables.

Ross Bamford wrote:
> On Wed, 2006-03-29 at 13:28 +0900, brez! !! wrote:
>
> > I'm looking for a way to iterate over two arrays and sum or multiply or
> > whatever each element resulting in a new array of the summed elements,
> > e.g.
> >
> > a[0]+b[0], a[1]+b[1], ... a[n]+b[n]
>
> Just a footnote to the other solutions you have for this, you can avoid
> inject to make it a bit shorter using map (thanks to the way block
> argument assignment works with arrays):
>
> ary = [1,2,3,4,5]
> # => [1, 2, 3, 4, 5]
>
> bry = ary.dup
> # => [1, 2, 3, 4, 5]
>
> ary.zip(bry).map! { |a,b| a+b }
> # => [2, 4, 6, 8, 10]
> 
> -- 
> Ross Bamford - rosco / roscopeco.REMOVE.co.uk