We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
二 func t2() (a int) { defer func() { a++ }() return 1 } 输出:2
改为输出1
The text was updated successfully, but these errors were encountered:
应该是2吧,因为定义了返回的变量为a,在return之后(传递的是a的引用),defer后跟着的匿名函数执行后 a变为2,所以返回值应该是2。
Sorry, something went wrong.
No branches or pull requests
二
func t2() (a int) {
defer func() {
a++
}()
return 1
}
输出:2
改为输出1
The text was updated successfully, but these errors were encountered: