How can I join multiple slices of the same entity into one slice?
Or how do I push a new entity value into a slice of the entity?
问问题
358 次
2 回答
4
append 内置函数为您完成了这两项工作。像这样使用它:
a := []int{1, 2}
a = append(a, 3)
b := []int{4, 5}
a = append(a, b...)
// a now is []int{1, 2, 3, 4, 5}
如果您需要有关如何使用切片的更多信息,我建议您阅读切片:用法和内部。
于 2013-03-17T07:53:25.487 回答