Curriculum Types & methods Nil & zero values exercise 2 · mcq
Nil & zero values
Only some Go types can hold nil. Numbers, strings, structs,
and booleans CAN'T — their zero values are 0, "", the
zero-struct, and false respectively, none of which is nil.
The nil-able types share a property: they're all REFERENCE
shapes under the hood (a pointer-y header that can point at
nothing).
Which of the following is the COMPLETE list of nil-able types
in Go?
About this theme
Every type has a zero value — what an uninitialised variable of that type holds. For numbers: 0. For strings: "". For bools: false. For pointers, interfaces, maps, slices, channels, and functions: nil. nil is *not* TypeScript's undefined — it's a typed absence, and conflating "nil pointer" with "nil interface" is one of the classic Go bugs.