The zero value of a slice is not nil
I was following the example https://tour.golang.org/moretypes/10 I modified the code expecting to get the same result. I did not. Is this a bug, or a documentation error? The tour states A nil slice has a length and capacity of 0. My y variable has a length and capacity of 0. package main import "fmt" func myPrint(z []int) { fmt.Println(z, len(z), cap(z)) if z == nil { fmt.Println("nil!") } } func main() { var z []int y := []int {} myPrint(z) myPrint(y) } Here is my output. [] 0 0 nil! [] 0 0 I was expecting a second "nil"~ Why didn't I get it? The doc you referenced states that a nil slice