Skip to content

Instantly share code, notes, and snippets.

@SeanPlusPlus
Created October 28, 2011 04:22
Show Gist options
  • Save SeanPlusPlus/1321615 to your computer and use it in GitHub Desktop.
Save SeanPlusPlus/1321615 to your computer and use it in GitHub Desktop.
Multidimensional Ruby Hash
#!/usr/bin/ruby
presidents = {}
presidents["jefferson"] = "3","virginia"
presidents["truman"] = "33","missouri"
presidents["obama"] = "44","hawaii"
presidents.each do |k,v|
surname = k
number = v[0]
state = v[1]
puts "surname: #{surname}, number: #{number}, state: #{state}"
end
=begin
surname: jefferson, number: 3, state: virginia
surname: obama, number: 44, state: hawaii
surname: truman, number: 33, state: missouri
=end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment