From: Christoph Rippel Date: 2001-01-08T08:11:00+09:00 Subject: [ruby-talk:8797] Re: No :<, :>, etc. methods for Array > -----Original Message----- > From: Brian F. Feldman [mailto:green@FreeBSD.org] > Sent: Sunday, January 07, 2001 11:46 AM > To: ruby-talk ML > Subject: [ruby-talk:8782] Re: No :<, :>, etc. methods for Array > Except that I don't really ever see the need for the inject functionality > itself. A general sum method wouldn't prevent an inject method from being > created, and I feel it's much more generally important (if it were in > Enumerable, it feels natural next to min and max). > > I know you can define sum in terms of inject, but what is the point of > having inject if people are just going to use it to create sum? Obviously, your question is ``only'' a matter of taste. Personally I already dislike the inclusion of max,min and sort in the Array class instead of creating a proper ``array > sortable array > numeric array'' class hierarchy. My secret wish for 1.7 would be the creation of a parallel (for legacy reasons) more fine grained collection class hierarchy instead of the current everything is either an ``Array or Hash'' strategy, in which Arrays can take on the roles of Sets, MultiSets, Numerical Arrays, Stacks, etc. . Introducing specialized collection classes could make Ruby more efficient, clearly expresses the indent of usage and could provide a definite answer on whether a general #sum method should be included or what the proper definition of the intersection of arrays should be ... . > -----Original Message----- > From: gotoken@hanare00.math.sci.hokudai.ac.jp > [mailto:gotoken@hanare00.math.sci.hokudai.ac.jp]On Behalf Of GOTO > Kentaro > def sum(if_empty = 0) # Is the integer zero suitable? An alternative would be the introduction of a ZERO and ONE constants in the Numeric class (possibly overridden in subclasses)? Christoph