Answers for "go add to slice"

Go
6

go add to slice

var s []int
s = append(s, 0)
Posted by: Guest on April-10-2020
1

append a slice to a slice golang

// appendSliceToSlice method  appends slice y to x 
func appendSliceToSlice() {
	x := []int{1,2,3}
	y := []int{4,5,6}
	x = append(x, y...)
    fmt.Println(x)	// output: [1 2 3 4 5 6]
}
Posted by: Guest on July-03-2021

Browse Popular Code Answers by Language