Playground
Edit the code and run it. Choose Debug to follow it one statement at a time.
func make_counter(start: Int, step: Int): Func { let value = start ret func(): Int { value = value + step ret value }}let next = make_counter(0, 1)let tens = make_counter(0, 10)print("next: {next()}")print("next: {next()}")print("tens: {tens()}")print("next: {next()}")print("tens: {tens()}")Your code runs in this browser. Controls and execution limits →