Append Array to Go Slice

This commit is contained in:
Mihalis Tsoukalos 2019-01-23 09:27:54 +02:00
commit b77cad454c

View file

@ -9,9 +9,12 @@ func main() {
a := [3]int{4, 5, 6}
ref := a[:]
fmt.Println(ref)
fmt.Println("Existing array:\t", ref)
t := append(s, ref...)
fmt.Println(t)
fmt.Println("New slice:\t", t)
s = append(s, ref...)
fmt.Println(s)
fmt.Println("Existing slice:\t", s)
s = append(s, s...)
fmt.Println("s+s:\t\t", s)
}