A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-8.go
1packagemain
2
3import"fmt"
4
5funcf()(nint){
6deferfunc(){n=99}()
7return1
8}
9
10funcmain(){
11fmt.Println(f())
12}
Defer
Answer & explanation
Console output
99
Why
return 1 assigns 1 to the named return n, then the deferred function runs and overwrites it with n = 99. Because defer executes after the return value is set but before the caller resumes, the caller sees 99, not 1.