Closure
Closures are self-contained blocks of functionality that can be passed around and used in your code. Closures can capture and store references to any constants and variables from the context in which they are defined. Closures can be nested and can be anonymous (without a name):
func f1(a) {
return func(b) {
return a + b;
}
}
func main() {
var addTen = f1(10);
return addTen(20); // result is 30
}
TO DO: more examples and explanations