func insert(slice *[]interface{}, index int, value interface{}) {
rear := append([]interface{}{}, (*slice)[index:]...)
*slice = append(append((*slice)[:index], value), rear...)
}
s1 := []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k"}
insert(s1, 5, "A")
//报错 cannot use str (type []string) as type *[]interface {} in argument to insert
如何把insert函数interface改成string,不只能用string了? interface怎么传?
芜湖不芜
九州编程
相关分类