How they really work
These 4 methods are defined in Enumerable
and check whether respectively none, one and only one, at least one or all elements are ‘true’. As a reminder, in Ruby only nil
and false
are considered ‘false’, all the rest being ‘true’. So be careful, it’s not just related to the number of elements in the Enumerable
.
Unlike grep
, a proc is used with a block to realize complex conditions.
And, just like grep
, you can use a parameter as a pattern thanks to the ===
method.
Finally, a little quiz: what about this edge case?