should not use nil as default value for Enumerable#count since it prevent counting nil in enums; ref #1887

This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-03-18 23:50:31 +09:00
parent 290faf88df
commit 575d919122
+2 -2
View File
@@ -209,14 +209,14 @@ module Enumerable
end
end
def count(v=nil, &block)
def count(v=NONE, &block)
count = 0
if block
self.each do |e|
count += 1 if block.call(e)
end
else
if v == nil
if v == NONE
self.each { count += 1 }
else
self.each do |e|