From: Florian Gross Date: 2005-03-18T01:34:49+09:00 Subject: Re: Array#nitems and Object#nil? Yukihiro Matsumoto wrote: > |On another note: Can we perhaps introduce Enumerable#count which returns > |the number of elements for which the block is true? I know that we can > |do .find_all { ... }.size, but constructing an Array of all elements > |just to get its size seems wasteful. > > enum.inject(0){|i,j| j ? i + 1 : i } > > No array construction, bit harder to read than #count. Is it too rare to deserve a built-in short cut?