golang 数组中插入数组

不浪人 ·
<code> package main import "fmt" func main() { s := []interface{}{1, 2, 3, 4, 5, 6, 7, 8} s1 := []interface{}{} // HERE: for _, v := range s { if v == 4 || v == 6 || v == 7 { s1 = append(s1, "(", v, v, ")") } else { s1 = append(s1, v) } } fmt.Println("s1=", s1) } </code>
#4
更多评论
package main import "fmt" func main() { s := []interface{}{1, 2, 3, 4, 5, 6, 7, 8} s1 := []interface{}{} // HERE: for _, v := range s { if v == 4 || v == 6 || v == 7 { s1 = append(s1, "(", v, v, ")") } else { s1 = append(s1, v) } } fmt.Println("s1=", s1) }
#1
` package main import "fmt" func main() { s := []interface{}{1, 2, 3, 4, 5, 6, 7, 8} s1 := []interface{}{} // HERE: for _, v := range s { if v == 4 || v == 6 || v == 7 { s1 = append(s1, "(", v, v, ")") } else { s1 = append(s1, v) } } fmt.Println("s1=", s1) } `
#2