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