Created
January 30, 2010 11:18
-
-
Save tatey/290514 to your computer and use it in GitHub Desktop.
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
h = {:a => 1, :b => 2, :c => 3} | |
h.each do |pair| | |
# pair is an Array | |
puts "key: #{pair.first}, value :#{pair.last}" | |
end | |
h.each do |key, value| | |
puts "key: #{key}, value :#{value}" | |
end | |
# Expected output | |
# | |
# key: c, value :3 | |
# key: a, value :1 | |
# key: b, value :2 | |
# key: c, value :3 | |
# key: a, value :1 | |
# key: b, value :2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment