Skip to content
instance method

Hash#delete_if

() { (K, V) -> ::boolish } -> self
() -> ::Enumerator[[ K, V ], self]
delete_if {|key, value| ... } → self
delete_if → new_enumerator

With a block given, calls the block with each key-value pair, deletes each entry for which the block returns a truthy value, and returns self:

Example
h = {foo: 0, bar: 1, baz: 2}
h.delete_if {|key, value| value > 0 } # => {foo: 0}

With no block given, returns a new Enumerator.

Related: see Methods for Deleting.

See also #delete #dig #default_proc= #each also in 4.1 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0