From: gotoken@... (GOTO Kentaro) Date: 2000-03-23T11:34:42+09:00 Subject: [ruby-talk:02094] Re: Array Gotchas Hi, In message "[ruby-talk:02091] Array Gotchas" on 00/03/22, "Dat Nguyen" writes: >While I was wondering why '+' was the concatenation and '-' was the >subtraction, I learned that Array indeed has the concat(other) method, but >not the substract(other) method and many other explicite spelling ones. > >There is already '+' for concatenation, why concat(other). When >concat(other) why not substract(other) also. And what about union(other), >etc. > >This is a sort of incompleteness and redundancy. At first, `+' and `concat' is slightly different. a, b = [1, 2, 3], [4, 5, 6] a + b; p a #=> [1, 2, 3] a.concat b; p a #=> [1, 2, 3, 4, 5, 6] Second, `substract' does indeed not exist. If you would strongly like to add the method as built-in one, we would start discussion. Or, you can define as follows: class Array def substract(other) replace(self - other) end end a, b = [1, 2, 3, 4, 5, 6], [1, 3, 5] a - b; p a #=> [1, 2, 3, 4, 5, 6] a.substract b; p a #=> [2, 4, 6] Regards, -- gotoken