Values & References7 / 15
Up next

Slices are reference-like

package main

import "fmt"

// the slice header is copied, but it points at the same array
func zeroFirst(v []int) {
	v[0] = 0
}

func main() {
	nums := []int{1, 2, 3}
	zeroFirst(nums)
	fmt.Println(nums) // [0 2 3]
}
What you're solving

the callee's writes are visible