← Back to archive

Stdle #179 · defer · 2026-12-02

What does this Go snippet output?

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

package main
import "fmt"
type P struct{ x int }
func (p *P) Bump() { fmt.Println(p.x) }
func main() {
p := &P{x: 3}
defer p.Bump()
p.x = 7
fmt.Println("mutated")
}
Defer
2 lines
4 attempts left

Answer & explanation