deleteIf

.deleteIf() { |element| ... }

Yields each element in turn into the attached block. If the block returns true, then the element is removed from the array.

Note that unlike 'filter', this works directly on this array, it does not return a copy.

ns = [ 10, 20, 30, 60, 70, 80 ]

// removes all values greater than 50
ns.deleteIf() { |n| return n > 50 }

This is the opposite of 'filter'.

See also

delete - filter