← Back to archive

Stdle #77 · classes · 2026-08-22

What does this Go snippet output?

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

package main
import "fmt"
type Vec struct{ X int }
func (v Vec) Scaled() Vec { v.X *= 2; return v }
func main() {
v := Vec{X: 5}
w := v.Scaled()
fmt.Println(v.X, w.X)
}
Classes
4 attempts left

Answer & explanation