News for hackers. Stuff that matters.
Re:My Objection to Array#sum by jsf on Thursday April 09, 2009 @02:21PM (#554860)
The difference between [1, "two"].sum and 1 + "two" is that in the second case you are passing "two" to 1's :+ method, that's an argument error, it doesn't depend on 1's state. In the first case you are not giving any argument to the method, so you shouldn't get an error. From the point of view of the array's user the array is now in an invalid state and that's not something the array should have allowed to happen.

There are no comments on this comment yet.