大佬教程收集整理的这篇文章主要介绍了golang中“Type`的含义是什么?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
// The append built-in function appends elements to the end of a slice. If // it has sufficient capacity,the desTination is resliced to accommodate the // new elements. If it does not,a new underlying array will be allocated. // Append returns the updated slice. it is therefore necessary to store the // result of append,often in the variable holding the slice itself: // slice = append(slice,elem1,elem2) // slice = append(slice,anotherSlice...) // As a special case,it is legal to append a String to a byte slice,like this: // slice = append([]byte("Hello "),"world"...) func append(slice []Type,elems ...TypE) []Type
最后一行让我感到非常困惑.我不知道有关……的意思.
这是其他代码.
package main import "fmt" func main() { s := []int{1,2,3,4,5} s1 := s[:2] s2 := s[2:] s3 := append(s1,s2...) fmt.Println(s1,s2,s3)
}
结果是
[1 2] [3 4 5] [1 2 3 4 5]
我想关于…的功能是从elems中选择所有元素.
我找不到官方的解释
以上是大佬教程为你收集整理的golang中“Type`的含义是什么?全部内容,希望文章能够帮你解决golang中“Type`的含义是什么?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。