提交 ea0eb02f 编写于 作者: J Julius Markūnas

#many? uses count instead of select - a bit faster

上级 e9f9ce97
......@@ -96,7 +96,7 @@ def index_by
# Returns true if the collection has more than 1 element. Functionally equivalent to collection.size > 1.
# Can be called with a block too, much like any?, so people.many? { |p| p.age > 26 } returns true if more than 1 person is over 26.
def many?(&block)
size = block_given? ? select(&block).size : self.size
size = block_given? ? count(&block) : self.size
size > 1
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册