← Back to archive

Stdle #96 · interfaces · 2026-09-10

What does this Go snippet output?

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

package main
import "fmt"
type W struct{ v int }
func (w *W) String() string { return fmt.Sprintf("W(%d)", w.v) }
func main() {
w := &W{7}
fmt.Println(w)
}
Interfaces
4 attempts left

Answer & explanation