Created
September 4, 2008 16:57
-
-
Save ebot/8810 to your computer and use it in GitHub Desktop.
Sample of using an array of hashes inside a hash. Pastie at http://pastie.org/266042
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create the contact information. | |
contact = { | |
:name => 'John Doe', | |
:phone_numbers => [ | |
{:description => 'home', | |
:number => '555.555.6304'}, | |
{:description => 'cell', | |
:number => '555.555.6300'}, | |
{:description => 'work', | |
:number => '510.555.2177'} | |
] | |
} | |
# Display the contact information. | |
puts "\n---------------------------------------------------" | |
puts contact[:name] | |
puts '---------------------------------------------------' | |
contact[:phone_numbers].each do |val| | |
puts " #{val[:description]} - #{val[:number]}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment