A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-34.go
1packagemain
2
3import"fmt"
4
5typeSstruct{
6Items[]int
7Nint
8}
9
10funcmain(){
11varsS
12fmt.Println(s.Items==nil,len(s.Items),s.N)
13}
Classes
Answer & explanation
Console output
true 0 0
Why
The zero value of S sets every field to its own zero value: the Items slice becomes nil and N becomes 0. A nil slice is valid to use. Its length is 0 and it compares equal to nil. So the output is true 0 0, and the zero-value struct is ready to use without initialization.