← Back to archive

Stdle #148 · defer · 2026-11-01

What does this Go snippet output?

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

package main
import "fmt"
func main() {
x := 5
defer func(v int) { fmt.Println("captured", v) }(x)
x = 50
fmt.Println("local", x)
}
Defer
2 lines
4 attempts left

Answer & explanation