Array#none?

arr.none? { |element| block } -> true or false
Returns: boolean · Updated March 13, 2026 · Array Methods
arrays enumerable conditionals checking

none? is an Enumerable method that tests whether no element in a collection matches a given condition. It returns true if no elements satisfy the criteria, otherwise false.

Syntax

array.none? { |element| block }

Without a block, it checks for truthy values.

Parameters

ParameterTypeDefaultDescription
blockProcA condition to evaluate against each element

Examples

Basic usage

numbers = [1, 2, 3, 4, 5]

numbers.none? { |n| n < 0 }
# => true (no negative numbers)

numbers.none? { |n| n > 10 }
# => true

Without a block

[false, nil].none?
# => true (no truthy values)

[0, false, nil].none?
# => true

With pattern matching (Ruby 3.0+)

items = [1, 2, 3]

items.none?(String)
# => true (no string elements)

Common Patterns

Validation checks

# Ensure no duplicates exist
def unique?(collection)
  collection.none? { |x| collection.count(x) > 1 }
end

Short-circuit evaluation

none? stops after finding the first truthy result:

# Efficient: stops at first invalid item
items.none? { |i| invalid?(i) }

Errors

Empty arrays always return true:

[].none?
# => true

Performance Notes

none? iterates lazily and stops as soon as it finds a truthy result, making it efficient for large datasets.

See Also