Sha256: 35c03acc2202d24a4bbfa3771e65ea4fe8bf2ea667f0b76f81a628e1a4208479

Contents?: true

Size: 849 Bytes

Versions: 6

Compression:

Stored size: 849 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

6 entries across 6 versions & 1 rubygems

Version Path
facets-2.8.4 lib/core/facets/enumerable/none.rb
facets-2.8.3 lib/core/facets/enumerable/none.rb
facets-2.8.2 lib/core/facets/enumerable/none.rb
facets-2.8.1 lib/core/facets/enumerable/none.rb
facets-2.8.0 lib/core/facets/enumerable/none.rb
facets-2.7.0 lib/core/facets/enumerable/none.rb