What is the output?
m := map[string]int{}
m["a"]++
fmt.Println(m["a"], m["b"])
- 1 0
- 0 0
- 1 1
- panic
Reading a missing key yields the zero value, so m["a"]++ starts from 0 and m["b"] prints 0.
Play Problem Solving ▸
m := map[string]int{}
m["a"]++
fmt.Println(m["a"], m["b"])