Closed flyingmutant closed 2 years ago
The only time I can think of where go will handle those differently is in comparison to nil. For example, the following will only print "a is nil" once:
var a []int
if a == nil {
fmt.Println("a is nil") // this will print
}
a = []int{}
if a == nil {
fmt.Println("a is nil") // this won't
}
Closing as it looks like there is not a lot of value in this.
As there is code that can work with
a := []int{}
, but fail withvar a []int
.Can we treat empty slices as having something like
len = -1
during generation?