"Dat Nguyen" <thucdat / hotmail.com> writes: > According to the Ruby manual: > self + other > The array concatenation > > This takes away the other natural operator addition or plus. There are > applications that need to add two numeric arrays with the same dimension, > no? > > Would the solution be creating a subclass that introduces a new method like: > self.add other > > But where would the sum go? Perhaps you could use the Matrix package - a vector is a Matrix with only one row (or only one column, depending on how you look at it) Alternatively, you could implement your own using something like: require 'delegate' class Vector < SimpleDelegator attr :value def initialize(anArray) super(anArray) end def +(aVector) raise "Size mismatch" if size != aVector.size i = -1 collect { |me| me + aVector[i += 1] } end end v1 = Vector.new [ 1,2,3,4,5 ] v2 = Vector.new [ 10, 12, 14, 16, 18 ] p (v1 + v2) Dave ps. Question to the list: what's a better way of concisely implementing the parallel iteration through the two arrays?