Skip to content

Instantly share code, notes, and snippets.

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