Skip to content

Instantly share code, notes, and snippets.

@tsevdos
Created December 10, 2015 22:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsevdos/7ea0074a5933aa9866e7 to your computer and use it in GitHub Desktop.
Save tsevdos/7ea0074a5933aa9866e7 to your computer and use it in GitHub Desktop.
Ruby Hash iteration with index
months = { January: 31, February: 28, March: 31, April: 30, May: 31, June: 30, July: 31, August: 31, September: 30, October: 31, November: 30, December: 31 }
months.each_with_index do |(key, val), i|
puts "#{i}: #{key} has #{val} days"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment