直接看代码
func main(){
var ff []int
f:=[]int{}
fmt.Println(ff==nil) // true
fmt.Println(len(ff),cap(ff)) //0 0
fmt.Println(f==nil) //false
fmt.Println(len(f),cap(f)) //0 0
}
输出:
true
0 0
0 0
false
直接看代码
func main(){
var ff []int
f:=[]int{}
fmt.Println(ff==nil) // true
fmt.Println(len(ff),cap(ff)) //0 0
fmt.Println(f==nil) //false
fmt.Println(len(f),cap(f)) //0 0
}
输出:
true
0 0
0 0
false