A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-66.go
1packagemain
2
3import"fmt"
4
5funcvalue()(nint){
6deferfunc(){n++}()
7return10
8}
9
10funcmain(){
11fmt.Println(value())
12}
Defer
Answer & explanation
Console output
11
Why
return 10 first assigns 10 to the named return value n, then the deferred functions execute. The closure does n++, so n becomes 11 before control returns to the caller. With a named return, defer can mutate the value the caller receives.