From: Jason Nordwick Date: 2006-09-09T02:15:29+09:00 Subject: Re: symbol tricks Gavin Kistner wrote: > From: Jason Nordwick [mailto:jason@adapt.com] >> 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: > Wouldn't that break pretty much everything else that used + for concatenation? -j > 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] >