Deviopath › Go

Make a Counter

Medium · Closures

A closure captures variables around it. MakeCounter(start) returns a function that adds 1 each time it is called and returns the new value. The first call returns start+1.

RunCounter(start, times) is already written and returns every value the counter produced.

Next: Defer Order