Go Language: Slices
A few weeks ago I talked about arrays in Go. This time I’m going to cover slices, which are built on top of arrays.
In my previous post I showed the difference between doing this:
1
2
3
4
5
6
7
8
9
10
11
12
func doSomething(arr [3]int) {
arr[0] = 5
}
func main() {
a := [3]int{1, 2, 3}
doSomething(a)
// Prints [1 2 3]
fmt.Println(a)
}