Medium
Apprentice
SpeedRun
maps
zero-values
panics
Go: Reading From a Nil Map
+170 XP · 4 min · attempt 1
Problem
Consider:
var m map[string]int // nil map, never make()'d
v := m["missing"] // line A: read
m["x"] = 1 // line B: write
Which line crashes? Answer with one of: `A`, `B`, `both`, or `neither`.
Starter
// Reading from a nil map returns the zero value silently.
// Writing to a nil map panics with: assignment to entry in nil map.
Your answer
Playing as a guest — you'll be asked for a display name on submit. Log in to keep your XP across devices.