Project

General

Profile

Actions

Bug #6473

closed

Enumerable#count

Added by no6v (Nobuhiro IMAI) almost 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.0.0dev (2012-05-19 trunk 35705) [x86_64-linux]
Backport:
[ruby-dev:45659]

Description

=begin
Enumerable#count には、

Returns the number of items in enum if it responds to a #size call,
otherwise the items are counted through enumeration. If an argument is

というコメントが書いてありますが、実際には

class E
include Enumerable

def each
end

def size
1
end
end

e = E.new
e.size # => 1
e.count # => 0

size は呼ばれていないようです。1.8 系や 1.9.1 の頃は 0 ではなく 1 が返っていたようです。
=end


Files

enum_count.patch (919 Bytes) enum_count.patch no6v (Nobuhiro IMAI), 05/21/2012 03:19 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0