https://studygolang.com/articles/14510?fr=sidebar 转
数组初始化
切片初始化
这样初始化会报错,数组6后面要换hang的话,要加逗号,
创建切片
切片
添加append
源码
func append(slice []Type, elems ...Type) []Type
append的用法有两种:
slice = append(slice, elem1, elem2)
slice = append(anotherSlice)
第一个是给slice添加任意个数据(0-n)
第二个是用新数组覆盖原数组
输出格式方法
append
结果