Closures

A closure occurs when an anonymous function in Go has access to its surroundings. Then it can maintain a unique state of its own. The state is then isolated as we create new instances of the function.


func MyFunction(string parameter) func() string {
    return func() string {
        return parameter
    }
}
                        
closures.go