We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func main() { scores := make([]int, 0, 5) c := cap(scores) fmt.Println(c) for i := 0; i < 25; i++ { scores = append(scores, i) // 如果容量已经改变,go为了容下这些新数据,不得不增长数组的长度 if cap(scores) != c { c = cap(scores) fmt.Println(c) } } } 看到文章写的是,扩容三次5、10、20 但是代码实际执行的时候是6、24、48
func main() { scores := make([]int, 0, 5) c := cap(scores) fmt.Println(c) for i := 0; i < 25; i++ { scores = append(scores, i) // 如果容量已经改变,go为了容下这些新数据,不得不增长数组的长度 if cap(scores) != c { c = cap(scores) fmt.Println(c) } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
func main() { scores := make([]int, 0, 5) c := cap(scores) fmt.Println(c) for i := 0; i < 25; i++ { scores = append(scores, i) // 如果容量已经改变,go为了容下这些新数据,不得不增长数组的长度 if cap(scores) != c { c = cap(scores) fmt.Println(c) } } }
看到文章写的是,扩容三次5、10、20
但是代码实际执行的时候是6、24、48
The text was updated successfully, but these errors were encountered: