Wouldn't this work by reference? The referenced value would be the same in both contexts.
Honestly, am I missing something?
Honestly, am I missing something?
So, the version that prints 1 is
func a() {
i := 0
defer func(){
fmt.Println(i)
}()
i++
return
}