mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
docs: clarify len and cap attributes for arrays (#10724)
This commit is contained in:
parent
075e09b10e
commit
fbd6b91086
10
doc/docs.md
10
doc/docs.md
@ -637,11 +637,11 @@ println(nums) // `[1, 5, 3]`
|
|||||||
```
|
```
|
||||||
#### Array Properties
|
#### Array Properties
|
||||||
There are two properties that control the "size" of an array:
|
There are two properties that control the "size" of an array:
|
||||||
* `len`: *length* - the number of defined elements of the array
|
* `len`: *length* - the number of pre-allocated and initialized elements in the array
|
||||||
* `cap`: *capacity* - the number of elements for which memory space has been reserved. The array can
|
* `cap`: *capacity* - the amount of memory space which has been reserved for elements,
|
||||||
grow up to this size without being reallocated. Usually, V takes care of
|
but not initialized or counted as elements. The array can grow up to this size without
|
||||||
this property automatically but there are cases where the user may want to do manual
|
being reallocated. Usually, V takes care of this property automatically but there are
|
||||||
optimizations (see [below](#array-initialization)).
|
cases where the user may want to do manual optimizations (see [below](#array-initialization)).
|
||||||
|
|
||||||
```v
|
```v
|
||||||
mut nums := [1, 2, 3]
|
mut nums := [1, 2, 3]
|
||||||
|
Loading…
Reference in New Issue
Block a user