添加元素 append
list = append(list, item)
//拼接两个slice
list = append(list, anotherList...)
删除特定原素,i位置元素,效率很高
testList = append(testList [:i], testList [i+1:]...)
本文详细介绍了Go语言中切片的添加元素和删除特定元素的操作方法。包括使用append函数添加单个元素或拼接切片,以及通过切片语法高效地删除指定位置的元素。
添加元素 append
list = append(list, item)
//拼接两个slice
list = append(list, anotherList...)
删除特定原素,i位置元素,效率很高
testList = append(testList [:i], testList [i+1:]...)
5078

被折叠的 条评论
为什么被折叠?