Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Go
/
Go
A map may legitimately store zero. How should code distinguish an absent key from a prese…
from Go
intermediate
1 min
A map may legitimately store zero. How should code distinguish an absent key from a present key mapped to zero?
Use the two-result lookup `value, ok := counts[key]`.
Test only whether `counts[key] == 0`.
Range over the map because lookup cannot report presence.
Check
Ask AI about this kata
Report an error
previous kata
A sentinel has been wrapped twice. Which check preserves the caller contract?
Quiz
next kata
Give the runtime failure message produced by assigning an entry to a nil map
Fill in
A new version is available
Reload