Printing a Hash : Print Hash « Hash « Ruby






Printing a Hash


h = {}
h[:name] = "Robert"
h[:nickname] = "Bob"
h[:age] = 43
h[:email_addresses] = {:home => "bob@example.com",
                       :work => "robert@example.com"}
puts h

puts h[:email_addresses]

p h[:email_addresses]

p h

 








Related examples in the same category

1.using puts on a hash in Ruby doesn't result in as nice a display as it does for arrays
2.Print a hash with PP module
3.Print out a nested hash