Deleting and Clearing a Hash : delete « Hash « Ruby






Deleting and Clearing a Hash


# You can delete key-value pairs from a hash with the delete method. 

myHash = { 1 => "One", 2 => "Two", 3 => "Three", 4 =>"Four", 5 => "Five" }

# I'll delete the pair identified by key 5:

myHash.delete( 5 ) # => "Five"

 








Related examples in the same category

1.Deleting Hash Elements
2.Delete element from hash
3.pass a block to your call to delete.