Akinori MUSHA wrote:
> At Thu, 29 May 2008 03:03:01 +0900,
> David Flanagan wrote:
>> Array.nitems has just been removed from 1.9, and as near as I can make
>> out from trying to read ruby-dev, Enumerable.count is suggested as a
>> replacement.
> 
> I didn't think there was a supporter for the method, since even Keiju
> himself, the father of the method, said in an interview that he hated
> it that he added the method of such a strange feature.

I wouldn't call myself a "supporter" of nitems, though I'm a little 
surprised it is being removed without being deprecated first. I agree 
that it is a strange feature--the kind of thing that a C programmer 
without dynamic arrays might want.

I've re-thought my position. If nitems is so strange that it should be 
removed, then it doesn't make sense to transfer that strange behavior to 
a new method. Conversely, if compatibility is so important that porting 
nitems is a concern, then we should just keep nitems.

In neither case does it make sense to patch the count method the way I 
proposed.  So I retract the patch I sent.  Sorry.

> 1) counting the number of all elements (the same as size/length for Array)

This would probably be more useful than returning an Enumerator.

Note that in the case of Enumerable#count, it is more than just an alias 
for size/length: it defines new functionality for enumerable objects 
like ranges. Is it necessary to define Hash#count so that it has similar 
performance characteristics to size when invoked without arguments on a 
  hash?

	David

> 2) counting the number of "true" elements (not nil nor false)
> 3) counting the number of unique elements ([1,2,3,4,2,2,1].count == 4)
> 
> What do you think?
> 
> --
> Akinori MUSHA / http://akinori.org/