As far as I can tell your version is different from zipping. Your results will have the length of the longer input, while the zipping variants will have the length of the shorter input.
I just remembered
zipWith from Haskell, and it seems as if
Enumerable#zip can take a block, it works different from what I am used from haskell though...
In ruby the block passed to
Enumerable#zip is executed for its sideeffects only, none of the inputs is changed, neither is an accumulator returned, so we have to build a result array in the block:
a = [1, 2, 3, 4, 5]
b = [5, 4, 3, 2, 1]
r = 
a.zip(b) do |x, y| c << x + y end
#=> [6, 6, 6, 6, 6]
At least in theory, this should not allocate more than 4 blocks at once, (2 for input, one for current result and one for next result when current outgrows capazity), though due to GC and stuff older chunks may survive as long as they do.
But GC does trick us in any of the aforementioned solutions to the problem.