Anonymous functions
package main
import "fmt"
func main() {
fmt.Println("Start")
run(func() {
fmt.Println("Hello")
})
fmt.Println("End")
}
func run(f func()) {
fmt.Printf("%T\n", f)
f()
}
Start
func()
Hello
End
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
package main
import "fmt"
func main() {
fmt.Println("Start")
run(func() {
fmt.Println("Hello")
})
fmt.Println("End")
}
func run(f func()) {
fmt.Printf("%T\n", f)
f()
}
Start
func()
Hello
End