Ruby Enumerables: ‘any’, ‘all’, ‘none’, and ‘find’

Sekou Dosso
Nov 11, 2020

Ruby offers various enumerables on collections that check for validity of the objects within it.

Consider the following example:

The any? method returns true if the block ever returns a value other than false or nil for any element passed to it:

The all? method returns true if the block never returns false or nil for any element passed to it:

The none? method returns true if the block never returns true for any element passed to it:

The find method returns the first element for which block is not false:

--

--