Last active
June 10, 2020 01:17
-
-
Save nobeans/4d21cc85146b6fc9dff56455d95324fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main() { | |
l1 := make([]string, 0, 0) | |
fmt.Println(append(l1, "1")) | |
fmt.Println(append(l1, "2")) | |
fmt.Println(append(l1, "3")) | |
fmt.Println(append(l1, "4"), append(l1, "5"), append(l1, "6")) | |
fmt.Println(append(l1, "7")) | |
// => | |
// [1] | |
// [2] | |
// [3] | |
// [4] [5] [6] | |
// [7] | |
l2 := make([]string, 0, 1) | |
fmt.Println(append(l2, "1")) | |
fmt.Println(append(l2, "2")) | |
fmt.Println(append(l2, "3")) | |
fmt.Println(append(l2, "4"), append(l2, "5"), append(l2, "6")) | |
fmt.Println(append(l2, "7")) | |
// => | |
// [1] | |
// [2] | |
// [3] | |
// [6] [6] [6] <---- !!! | |
// [7] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment