method
keep_if
v2_6_3 -
Show latest stable
- Class:
Array
keep_if()public
Deletes every element of self for which the given block evaluates to false, and returns self.
If no block is given, an Enumerator is returned instead.
a = %w[ a b c d e f ] a.keep_if {|v| v =~ /[aeiou]/ } #=> ["a", "e"] a #=> ["a", "e"]
See also Array#select!.