Update 'content/posts/golang-append.md'
This commit is contained in:
parent
1cceb00a34
commit
083476e9b1
@ -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 :)")
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user