method

keep_if

Importance_1
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!.

Show source
Register or log in to add new notes.