Update 'content/posts/golang-append.md'

This commit is contained in:
Marcus Noble 2020-10-30 13:13:26 +00:00
parent 1cceb00a34
commit 083476e9b1
1 changed files with 8 additions and 8 deletions

View File

@ -47,15 +47,15 @@ package main
import "fmt"
func main() {
first := []int{0, 1, 2, 3, 4, 5, 6}
second := []int{4, 5, 6}
first := []int{0, 1, 2, 3, 4, 5, 6}
second := []int{4, 5, 6}
fmt.Println(first)
// -> [0 1 2 3 4 5 6]
fmt.Println(append(first[:2:2], second...))
// -> [0 1 4 5 6]
fmt.Println(first)
// -> [0 1 2 3 4 5 6]
fmt.Println(first)
// -> [0 1 2 3 4 5 6]
fmt.Println(append(first[:2:2], second...))
// -> [0 1 4 5 6]
fmt.Println(first)
// -> [0 1 2 3 4 5 6]
fmt.Println("Much better :)")
}
```