Look at these two blocks of code:
// return 0
func f() int {
res := 0
defer func(){
res++
}()
return res
}
I know that the defer expression is executed after the return expression.
But why is it different when there's a named return value?
Why doesn't the following function return a 0?
// return 1
func f() (res int) {
res = 0
defer func(){
res++
}()
return res
}