Skip to content

Instantly share code, notes, and snippets.

@carmelyne
Created January 29, 2009 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carmelyne/54500 to your computer and use it in GitHub Desktop.
Save carmelyne/54500 to your computer and use it in GitHub Desktop.
hash = { :water => 'wet', :fire => 'hot' }
puts hash[:fire] # Prints: hot
hash.each_pair do |key, value| # Or: hash.each do |key, value|
puts "#{key} is #{value}"
end
# Prints: water is wet
# fire is hot
hash.delete :water # Deletes :water => 'wet'
hash.delete_if {|key,value| value=='hot'} # Deletes :fire => 'hot'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment