instance method
many?
Ruby on Rails 7.1.6
Since v2.2.3Signature
many?()
Returns true if the enumerable has more than 1 element. Functionally equivalent to enum.to_a.size > 1. Can be called with a block too, much like any?, so people.many? { |p| p.age > 26 } returns true if more than one person is over 26.
Source
# File activesupport/lib/active_support/core_ext/enumerable.rb, line 93
def many?
cnt = 0
if block_given?
any? do |*args|
cnt += 1 if yield(*args)
cnt > 1
end
else
any? { (cnt += 1) > 1 }
end
end
Defined in activesupport/lib/active_support/core_ext/enumerable.rb line 93
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Enumerable