Values & References3 / 15
Up next

Maps are reference-like

package main

import "fmt"

// writes through m are seen by the caller
func addOne(m map[string]int) {
	m["count"]++
}

func main() {
	m := map[string]int{"count": 0}
	addOne(m)
	addOne(m)
	fmt.Println(m["count"]) // 2
}
What you're solving

a map value shares its backing store