Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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