← Back to archive

Stdle #169 · iteration · 2026-11-22

What does this Go snippet output?

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

package main
import "fmt"
func main() {
adders := []func() int{}
for i := 1; i <= 3; i++ {
adders = append(adders, func() int { return i * i })
}
for _, a := range adders {
fmt.Print(a(), " ")
}
fmt.Println()
}
Iteration
4 attempts left

Answer & explanation