Go by Example: Closures
Go by Example : Closures
Go supports anonymous functions , which can form closures . Anonymous functions are useful when you want to define a function inline without having to name it. | |
![]() | |
| |
This function
| |
| |
We call
| |
See the effect of the closure by calling
| |
To confirm that the state is unique to that particular function, create and test a new one. | |
| |
The last feature of functions we’ll look at for now is recursion. |
Next example: Recursion .
