Skip to content

Instantly share code, notes, and snippets.

@tatey
Created January 30, 2010 11:18
Show Gist options
  • Save tatey/290514 to your computer and use it in GitHub Desktop.
Save tatey/290514 to your computer and use it in GitHub Desktop.
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