Sha256: 21a26e5c7450e4c2ad2c48ce58af315237493a719c1635e82c03929743a4383e

Contents?: true

Size: 843 Bytes

Versions: 4

Compression:

Stored size: 843 Bytes

Contents

unless (RUBY_VERSION[0,3] == '1.9')

  module Enumerable

    # 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

4 entries across 4 versions & 1 rubygems

Version Path
facets-2.6.0 lib/core/facets/enumerable/none.rb
facets-2.5.0 lib/core/facets/enumerable/none.rb
facets-2.5.1 lib/core/facets/enumerable/none.rb
facets-2.5.2 lib/core/facets/enumerable/none.rb