PRACTICE / UNDERSTAND / REPEAT

Go: Maps

Practice maps with self-contained questions. Check your answer, then use the explanation to understand the reasoning.

32 questionsAnswers explainedFree · no login
Question 1 of 32

What happens when you read a missing key from a Go map?

Choose one answer
Answer & explanation

Answer: You get the element type’s zero value

A map lookup returns the zero value when absent; the comma-ok form distinguishes absent keys.