Skip to content

Instantly share code, notes, and snippets.

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