Skip to content

Conversation

ch3ny4ng
Copy link
Contributor

切片容量的计算不够清晰,只在一张图上得到了体现。为此添加描述和例子。

切片容量的计算不够清晰,只在一张图上得到了体现。为此添加描述和例子
@changkaiyan
Copy link

changkaiyan commented Aug 20, 2025 via email

g = make([]int, 3) // 有 3 个元素的切片, len 和 cap 都为 3
h = make([]int, 2, 3) // 有 2 个元素的切片, len 为 2, cap 为 3
i = make([]int, 0, 3) // 有 0 个元素的切片, len 为 0, cap 为 3
g = c[1:2] // 有 1 个元素的切片, len 为 1, cap 为 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

切片f已经可以说明此行要表达的东西了

@chai2010 chai2010 merged commit 4447d09 into chai2010:master Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants