Questions tagged «argument-unpacking»




4
将数组作为参数解包
因此,在Python和Ruby中,使用splat运算符(*)可以将数组解压缩为参数。在Javascript中,有.apply()函数。Go中有没有一种将数组/切片作为函数参数解包的方法?任何资源,这也将是巨大的! 与此类似: func my_func(a, b int) (int) { return a + b } func main() { arr := []int{2,4} sum := my_func(arr) } 如果我犯了语法错误或各种错误,我深表歉意。我是新手。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.