# Example: Use a lambda as a closure to capture runtime variables
def create_counter(start)
  lambda { start += 1 }
end
 
counter = create_counter(0)
puts counter.call   # Output: 1
puts counter.call   # Output: 2

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: