go语言闭包

func adder() func(int, int) int {
sum := 0
return func(x, y int) int {
sum = x * y
return sum
}
}


func main() {
pos := adder()

fmt.Println(pos(10, 10)

)

你可能感兴趣的:(go语言闭包)