Skip to content

Instantly share code, notes, and snippets.

@granolocks
Created March 13, 2012 13:22
Show Gist options
  • Save granolocks/2028717 to your computer and use it in GitHub Desktop.
Save granolocks/2028717 to your computer and use it in GitHub Desktop.
Loop with Enumerator
# 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