Functions
Go requires explicit returns, it won't automatically return the value of the last expression.
Multiple Return Values
Variadic Functions
Variadic functions can be called with any number of trailing arguments
For example,
fmt.Println()
is a common variadic function
Closures
Go supports anonymous functions, which can form
closures
It is useful when you want to define a function inline without having to name it.
Function
intSeq
returns another function, which we define anonymously in the body ofintSeq
The return function closes over the variable i to form a closure
Last updated