Skip to content

Instantly share code, notes, and snippets.

@th-in-gs
Created April 7, 2011 10:07
Show Gist options
  • Save th-in-gs/907479 to your computer and use it in GitHub Desktop.
Save th-in-gs/907479 to your computer and use it in GitHub Desktop.
Scottish Ruby Conference Charity Tutorial
def counter(start=0, increment=1)
lambda do
ret = start
start += increment
ret
end
end
result = counter(10, 2);
result2 = counter(10, 2);
puts result.call; # 10
puts result.call; # 12
puts result2.call; # 10
puts result2.call; # 12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment