i am reading the golang tutorial: https://tour.golang.org/moretypes/10
And i am confused about how fmt.Println
prints the nil
value, hope you could help me out.
package main
import "fmt"
func main() {
var z []int
fmt.Println("z: ", z)
if z == nil {
fmt.Println("z is nil!")
}
fmt.Println("nil:", nil)
}
the result is:
z: []
z is nil!
nil: <nil>
Since z is a nil, why is z printed as []
but not <nil>
?
thanks!