Go · Stage 5 – Grouping Data · Lesson 33 of 64

Maps and Key-Value Pairs

Look up values using meaningful keys.

Go code

ages := map[string]int{"Maya": 12}
fmt.Println(ages["Maya"])
Line-by-line explanation
  1. The map uses string keys and int values.
  2. Maya maps to 12.
  3. Square brackets look up the key.
Expected output
12

This is the expected result.