Last active
March 4, 2020 10:37
-
-
Save Zhang-Siyang/e701966d4d12022816c1750d7afa861c 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 test(a []int) { | |
a = append(a, 4) | |
} | |
func main() { | |
s := make([]int, 3, 4) | |
s[0] = 1 | |
s[1] = 2 | |
s[2] = 3 | |
fmt.Println(s) //[1 2 3] | |
test(s) | |
s = s[:4] | |
fmt.Println(s) //[1 2 3 4] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment