// main project main.go
package main
import (
"fmt"
)
func mm(str string, Nums ...int) {
var a []int //切片为nil
fmt.Println(len(a))
fmt.Println(a)
if a == nil {
fmt.Println("[]int comes in")
}
fmt.Println(len(Nums))
fmt.Println(Nums)
if Nums == nil {
fmt.Println("nil comes in")
}
}
func main() {
mm("a")
}
测试结果:
0
[]
[]int comes in
0
[]
nil comes in
成功: 进程退出代码 0.
有疑问加站长微信联系(非本文作者))