我一直试图弄清楚为什么这不起作用但不确定。沙盒中的错误是
main.go:16: syntax error: unexpected {, expecting )
代码:
package main
import "fmt"
type handler func(a func(b int))
func HandleSomething(h handler) {
//...
//d := h(5)
//h(5)
// ...
}
func main() {
var foo int
HandleSomething(handler(func(func(b int){
fmt.Printf("debug: foo in main is %d and %d", foo, b)
})))
}