Created
April 7, 2011 10:07
-
-
Save th-in-gs/907479 to your computer and use it in GitHub Desktop.
Scottish Ruby Conference Charity Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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