Print a hash with PP module : Print Hash « Hash « Ruby






Print a hash with PP module


require 'pp'

h = {}
h[:name] = "Robert"
h[:nickname] = "Bob"
h[:age] = 43
h[:email_addresses] = {:home => "[email protected]",
                       :work => "[email protected]"}

pp h[:email_addresses]
# {:home=>"[email protected]", :work=>"[email protected]"}

pp 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.Printing a Hash
3.Print out a nested hash