Go-函数多个形参
?
函數(shù)多個(gè)形參
1 package main 2 3 import "fmt" 4 5 func test(a int, agrs ...int) { 6 fmt.Println("a=", a) 7 fmt.Println("len(agrs)=", len(agrs)) 8 for i := 0; i < len(agrs); i++ { 9 fmt.Printf("agrs[%d]=%d\t", i, agrs[i]) 10 } 11 } 12 13 func main() { 14 test(1, 2, 3, 4) 15 } 16 //輸出 17 /* 18 a= 1 19 len(agrs)= 3 20 agrs[0]=2 agrs[1]=3 agrs[2]=4 21 */ View Code?
轉(zhuǎn)載于:https://www.cnblogs.com/Paul-watermelon/articles/10851735.html
總結(jié)
- 上一篇: 小程序中自定义头部标题栏
- 下一篇: usbip