should not use nil as default value for Enumerable#count since it prevent...

should not use nil as default value for Enumerable#count since it prevent counting nil in enums; ref #1887
parent 290faf88
......@@ -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|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment