A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-120.go
1packagemain
2
3import"fmt"
4
5typeCstruct{Vint}
6
7func(cC)Inc(){c.V++}
8
9funcmain(){
10c:=C{V:10}
11c.Inc()
12fmt.Println(c.V)
13}
Classes
Answer & explanation
Console output
10
Why
With a value receiver (c C), the method gets a copy of the struct on each call. c.V++ increments that copy and the change vanishes when Inc returns. The original c is untouched, so c.V is still 10. Only a pointer receiver would mutate the caller’s value.