Skip to content

Instantly share code, notes, and snippets.

@ebot
Created September 4, 2008 16:57
Show Gist options
  • Save ebot/8810 to your computer and use it in GitHub Desktop.
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
# 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