Created
March 13, 2012 13:22
-
-
Save granolocks/2028717 to your computer and use it in GitHub Desktop.
Loop with Enumerator
This file contains 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
# Enumerator to loop with | |
months = (1..12).to_a.reverse.each | |
# Integer to loop with | |
year = 1000 | |
# month counts down, then resets through loop | |
# year goes up to 2014 then ends | |
until year == 2014 do | |
begin | |
month = months.next | |
rescue StopIteration | |
months.rewind | |
month = months.next | |
end | |
puts "#{ month }/#{ year }" | |
year += 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment