A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-25.go
1packagemain
2
3import"fmt"
4
5funcmain(){
6rows:=[]struct{
7IDint
8}{{1},{2},{3}}
9fmt.Println(len(rows),rows[2].ID)
10}
Classes
Answer & explanation
Console output
3 3
Why
You can make a slice of an anonymous struct type defined inline. Here three elements are constructed with ID 1, 2, and 3. len(rows) is 3 and rows[2].ID is 3, so the output is 3 3. Anonymous struct slices are common for ad-hoc table-driven data.