golang func expression
- func expression
- assign a function to a variable
-
package main import ( "fmt" ) func main() { // func expression // assign a function to a variable f := func() { fmt.Println("my first func expression") } f() g := func(x int) { fmt.Println("the year big bother start watch:", x) } g(1984) }
- End