Ruby 2.5.0 was recently released.
Ruby has sequence predicates such as
which take a block
by passing every element of the sequence to it.
Ruby 2.5 allows using a shorthand for this by
passing a pattern argument.
case equality operator(===) is used
against every element of the sequence
and the pattern argument.
This allows us to write concise and shorthand expressions where block
is only used for comparisons.
This feature is applicable to
Similarities with Enumerable#grep
This feature is based on how
grep returns an array
of every element in the sequence
for which the
case equality operator(===)
by applying the pattern.
In this case,
all? and friends return true or false.
There is a proposal to add it for
reject as well.