From: Benoit Daloze Date: 2011-10-20T18:49:54+09:00 Subject: [ruby-core:40245] Re: [ruby-core:40244] Enumerable#count doesn’t call #size anymore Hi, On 20 October 2011 11:28, Nikolai Weibull wrote: > According to the documentation, Enumerable#count calls #size on the > object if it responds to it. > > This behavior was removed on October 31, 2009 (in Git > c0a0aa0c47f2cd5c97a35effb8b073eeb84b7d2d). > > The discrepancy between documentation and implementation > notwithstanding nor the fact that it�s been two years since the change > was made, I don�t think that this was an optimization that should be > removed on a whim. �I have come to depend on this behavior, as I much > prefer #count as a name to #length and #size in many cases. �Yes, > Array implements its own version of #count that is the same as #size, > but this isn�t true for, for example, Hash. > > Yes, Ruby 1.9 (or is that 2.0 now?) is still a moving target, but it > saddens me that changes like these can be made so easily without > notifying the community and � much, much worse � without updating the > relevant documentation. I totally agree, it seems a consistent and good optimization not worth to remove. I once wanted to add that feature back with Marc-Andr�'s Enumerable#size{,=} patch ( http://redmine.ruby-lang.org/issues/3715 ).