A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-9.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6w:="X"
7deferfmt.Print(w)
8w+="Y"
9deferfmt.Print(w)
10w+="Z"
11fmt.Print(w," ")
12}
Defer
Answer & explanation
Console output
XYZ XYX
Why
Strings are values, so each defer freezes w as it was at that line: "X" then "XY". The body prints "XYZ " (w is "XYZ" by then). Unwinding LIFO prints the later snapshot "XY" first, then "X", producing "XYZ XYX" on one line.