From: Robert Klemme Date: 2010-06-07T20:46:39+09:00 Subject: Re: inject method of Array class 2010/6/7 David A. Black : > On Mon, 7 Jun 2010, Rein Henrichs wrote: > >> On 2010-06-06 17:55:58 -0700, David A. Black said: >> I suspect that the majority are overwritten for performance reasons, >> although some of them surprise me as well. >> >> A linked list, for instance, would have a constant time #count because >> that state is kept on the list object and doesn't require an O(n) >> enumeration of the members. > > I think it's a mixture of performance reasons and things like what it > should return if there's no block (like Enumerable#map always > returning an array vs. Array#map returning its receiver). Array is > definitely the one that has the most overrides, with Hash coming in > second at 6 and IO having none. David, I guess you meant to write "... vs. Array#map! returning its receiver"? Note the exclamation mark. Array#map returns a new Array on every invocation. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/