Sha256: ba297493ad7ea7d7aca3802f6f83911803a53e5fcce13e46136e6000b94762d8
Contents?: true
Size: 864 Bytes
Versions: 7
Compression:
Stored size: 864 Bytes
Contents
module Enumerable unless method_defined?(:none?) # 1.8.7+ # Enumerable#none? is the logical opposite of the builtin method # Enumerable#any?. It returns +true+ if and only if _none_ of # the elements in the collection satisfy the predicate. # # If no predicate is provided, Enumerable#none? returns +true+ # if and only if _none_ of the elements have a true value # (i.e. not +nil+ or +false+). # # [].none? # => true # [nil].none? # => true # [5,8,9].none? # => false # (1...10).none? { |n| n < 0 } # => true # (1...10).none? { |n| n > 0 } # => false # # CREDIT: Gavin Sinclair def none? # :yield: e if block_given? not self.any? { |e| yield e } else not self.any? end end end end
Version data entries
7 entries across 6 versions & 1 rubygems