PRACTICE / UNDERSTAND / REPEAT

Go practice question

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

1 questionAnswers explainedFree · no login

Try this question

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.