Skip to content
instance method

Array#delete_if

() { (Elem item) -> ::boolish } -> self
() -> ::Enumerator[Elem, self]
delete_if {|element| ... } → self
delete_if → new_numerator

With a block given, calls the block with each element of self; removes the element if the block returns a truthy value; returns self:

Example
a = [:foo, 'bar', 2, 'bat']
a.delete_if {|element| element.to_s.start_with?('b') } # => [:foo, 2]

With no block given, returns a new Enumerator.

Related: see Methods for Deleting.

See also #delete_at #detect #delete #difference also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0