mirror of
https://github.com/gopl-zh/gopl-zh.github.com.git
synced 2024-12-24 22:08:57 +00:00
zz
This commit is contained in:
parent
fc2e1a20c5
commit
fde6468092
@ -1,5 +1,5 @@
|
||||
{
|
||||
"title": "Go编程语言",
|
||||
"title": "Go语言圣经",
|
||||
"description": "<The Go Programming Language>中文版",
|
||||
"language": "zh",
|
||||
"structure": {
|
||||
|
@ -124,8 +124,6 @@ make([]T, len)
|
||||
make([]T, len, cap) // same as make([]T, cap)[:len]
|
||||
```
|
||||
|
||||
Under the hood, make creates an unnamed array variable and returns a slice of it; the array is accessible only through the returned slice. In the first form, the slice is a view of the entire array. In the second, the slice is a view of only the array’s first len elements, but its capacity includes the entire array. The additional elements are set aside for future growth.
|
||||
|
||||
在底層,make創建了一個匿名的數組變量,然後返迴一個slice;隻有通過返迴的slice才能引用底層匿名的數組變量。在第一種語句中,slice是整個數組的view。在第二個語句中,slice隻引用了底層數組的前len個元素,但是容量將包含整個的數組。額外的元素是留給未來的增長用的。
|
||||
|
||||
{% include "./ch4-02-1.md" %}
|
||||
|
Loading…
Reference in New Issue
Block a user