← Back to archive

Stdle #150 · defer · 2026-11-03

What does this Go snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

package main
import "fmt"
func main() {
s := "x"
defer func() { fmt.Println(s) }()
defer func() { s = "y" }()
s = "z"
}
Defer
4 attempts left

Answer & explanation