Permalink
Browse files

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

  • Loading branch information...
dziulius committed Jul 11, 2011
1 parent e9f9ce9 commit ea0eb02f484f9220015aa62fd6435c0ae14cb710
Showing with 1 addition and 1 deletion.
  1. +1 −1 activesupport/lib/active_support/core_ext/enumerable.rb
@@ -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

0 comments on commit ea0eb02

Please sign in to comment.