Append Array to Go Slice
This commit is contained in:
parent
2376ebc771
commit
b77cad454c
1 changed files with 6 additions and 3 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue