← Back to archive

Stdle #94 · defer · 2026-09-08

What does this Go snippet output?

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

package main
import "fmt"
func f() (n int) {
defer func() { n = n * n }()
n = 4
return 3
}
func main() {
fmt.Println(f())
}
Defer
4 attempts left

Answer & explanation