Skip to content

Instantly share code, notes, and snippets.

@kjwierenga
Last active August 17, 2021 12:14
Show Gist options
  • Save kjwierenga/907473 to your computer and use it in GitHub Desktop.
Save kjwierenga/907473 to your computer and use it in GitHub Desktop.
def returning(value, &block)
yield
value
end
def counter(start, inc)
lambda do
returning start do
start += inc
end
end
end
result = counter(10, 2)
puts result.call
puts result.call
puts result.call
puts result.call
result = counter(2, 3)
puts result.call
puts result.call
puts result.call
puts result.call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment