Delete element from hash : delete « Hash « Ruby






Delete element from hash


myHash = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five" }
myHash.delete( 5 ) # => "Five"
p myHash # => {1=>"One", 2=>"Two", 3=>"Three", 4=>"Four"}

 








Related examples in the same category

1.Deleting Hash Elements
2.Deleting and Clearing a Hash
3.pass a block to your call to delete.