News for hackers. Stuff that matters.
Re:My Objection to Array#sum by _pius on Thursday April 09, 2009 @02:16PM (#554850)
It is about whether, when I look at the methods implemented by Array, it describes what arrays do or what arrays sometimes do or may do once in a while.

Sure. I think it's in Ruby's culture for people to write ultra-cute convenience methods and DSLs for this sort of thing, even if it makes it possible for someone to write code that doesn't make semantic sense.

I actually think that Array#sum is the least objectionable in a single project where summing the elements may be common, maybe objectionable in ActiveSupport where every Rails project gets it whether they sum arrays or not, and absolutely wrong in Ruby's core libraries where every Ruby programmer will get it.

Agree 100%. Arrays in Ruby core shouldn't be summing, they should be injecting.

There are no comments on this comment yet.