亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Go中“...Type”是什么意思?

Go中“...Type”是什么意思?

Go
慕標琳琳 2021-09-13 16:39:50
此代碼位于builti.go:// 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最后一行讓我感到非常困惑。我不知道是什么意思...Type。這些是其他代碼:package mainimport "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,但我還沒有找到官方解釋。它是什么?
查看完整描述

1 回答

?
慕容708150

TA貢獻1831條經驗 獲得超4個贊

builtin.go 中的代碼用作文檔。代碼未編譯。

...指出這個函數的最后一個參數是可變參數。Go 語言規范記錄了可變參數函數。簡而言之,可以使用任意數量的參數作為最終參數調用可變參數函數。

類型的部分為任何圍棋類型替身。


查看完整回答
反對 回復 2021-09-13
  • 1 回答
  • 0 關注
  • 211 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號