Skip to content

Instantly share code, notes, and snippets.

@baxter
Created April 7, 2011 09:57
Show Gist options
  • Save baxter/907452 to your computer and use it in GitHub Desktop.
Save baxter/907452 to your computer and use it in GitHub Desktop.
def counter(start=0, increment=1)
lambda do
original = start
start += increment
original
end
end
result = counter(2, 3)
puts result.call
puts result.call
puts result.call
puts result.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment