More Functions
Function Values
Functions are values too. They can be passed around just like other values. Function values may be used as function arguments and return values.
Example
Function Closures
Go functions may be closures. A closure is a function value that references variables from outside its body. The function may access and assign to the referenced variables; in this sense the function is "bound" to the variables.
Example 1 (No Parameter)
Example 2 (With Parameter)
More About Closure
Last updated
Was this helpful?