On 9/14/05, Masayoshi Takahashi <maki / rubycolor.org> wrote: > [ruby-dev:26895] Enumerable#count > > Satoru Takabayashi wrote a table of methods of Array > in Ruby, Python, JavaScript, Perl and C. > > http://namazu.org/~satoru/blog/archives/000043.html > > When he wrote it, he found that Ruby doesn't have > a method such as a.count(x) in Python. He wanted > to add Enumerable#count into Ruby. > > But in his next mail, he found that Enumerable#nitems > has block like a.nitems{|e| e == x}. He guessed it > may be enough to do. I think that it would not be a bad idea to add Enumerable#count as an alias for Enumerable#nitems, as while #nitems is somewhat sensible, it doesn't leap out as a "count items that are like this" method to me. I would tend to favour #select with #size or #inject if said method does not exist. > [ruby-dev:26924] enumerator > Nobuyoshi Nakada made a patch to return Enumerator > object when Enumerable method is called without > block. It's applied to each or each-like methods > in Array, Dir, Hash, IO, Range, String and Struct. > > http://www.rubyist.net/~nobu/ruby/enumerator.diff Um. Any chance of seeing this in Ruby 1.8.x? I'm supposing this is instead of a LocalJumpError. -austin -- Austin Ziegler * halostatue / gmail.com * Alternate: austin / halostatue.ca