defer和fmt.Println

求解为啥defer输出的不是最终值? ``` package main import "fmt" func main() { var i = new(int) defer func(i *int) { fmt.Println("3:", *i) }(i) defer fmt.Println("2:", *i) *i++ fmt.Println("1:", *i) } //1: 1 //2: 0 //3: 1 ``` 我猜应该是和println接收...阅读全文

2022-02-27 02:55:13