Delete if with block logics
myHash = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five" } myHash.delete_if { |key, value| key < 3 } # => {5=>"Five", 3=>"Three", 4=>"Four"}