From: Jason N. [mailto:[email protected]]
Plus for arrays and strings is concatenation. I don’t like it
either, b/c array plus should be addition of corresponding
elements, but that is the way things are.
That’s seems oddly specific to me, but if you don’t like it, change it:
a = [ 1, 2, 3 ]
b = [ 4, 5, 6 ]
p a+b
#=> [1, 2, 3, 4, 5, 6]
class Array
def +( other )
self.zip( other ).map{ |e| e[0]+e[1] }
end
end
p a+b
#=> [5, 7, 9]