Go

Writing To A Nil Map Panics in Go

GoMapsNil Mapsadvanced

A nil map reads fine but panics on write. Always create one with make or a literal before assigning into it.

expected output

true 0 0
map[ok:1]

Why practise typing this

Typing maps code builds muscle memory for the symbols and indentation Go uses most, which prose-based typing tests never cover. DevType measures your words per minute and accuracy on this snippet and tracks the individual characters you mistype, so later lessons can target them.

More Go practice

Browse all Go snippets →