From: not@... (Chris) Date: 2002-04-03T07:14:08+09:00 Subject: Re: Why isn't Math object-oriented? On 31 Mar 2002 18:29:13 -0800, jack_d_herrington@pobox.com (Jack Herrington) wrote in comp.lang.ruby: >a = [ 1, 2, 3 ] >b = [ 4, 5, 6 ] >c = a + b Intending to mean a matrix addition (which isn't defined by Ruby) >a = [ 'hi', 'there' ] >b = [ 'chucky', 'cheese' ] >c = a + b Intending to mean the Array method c = a.concat(b) I had always understood the "more than one way" argument but now I see that Ruby has become irreconcilably inconsistent. I expected to find add() defined in either Numeric or Math but it's just not there, even though Array defines both concat() and '+' as the same operation. And why use << to alter the current Array instance when concat! would be the method name used in any other class? It's probably too late (installed base too large) to fix Ruby now, but maybe the next evolution will start with a consistent object model. I hate to bring it up, but I think Microsoft hit the nail on the head when they designed VB to use different operators for addition versus concatenation rather than attempting to divine intent from context. Ignoring for a moment that Ruby has defined the '&' operator as an array intersection: a = [1, 2, 3] b = [4, 5, 6] c = ['hi', 'there'] d = ['chucky', 'cheese'] a + b == [5, 7, 9] a & b == [1, 2, 3, 4, 5, 6] c + d == [('hi' + 'chucky'), ('there' + 'cheese')] c & d == ['hi', 'there', 'chucky', 'cheese'] a + c == [(1 + 'hi'), (2 + 'there'), (3 + nil)] b & d == [4, 5, 6, 'chucky', 'cheese'] That still leaves the question of what '+' means when applied to strings, but at least arrays are out of the way.