相关疑难解决方法(0)

在Go中连接两个切片

我正在尝试将切片[1, 2]和切片组合在一起[3, 4].我怎么能在Go中这样做?

我试过了:

append([]int{1,2}, []int{3,4})
Run Code Online (Sandbox Code Playgroud)

但得到了:

cannot use []int literal (type []int) as type int in append
Run Code Online (Sandbox Code Playgroud)

但是,文档似乎表明这是可能的,我错过了什么?

slice = append(slice, anotherSlice...)
Run Code Online (Sandbox Code Playgroud)

append variadic-functions go slice

411
推荐指数
8
解决办法
23万
查看次数

标签 统计

append ×1

go ×1

slice ×1

variadic-functions ×1