From fbd6b910868890c3dfc813355e870ba5cb4feded Mon Sep 17 00:00:00 2001 From: JalonSolov Date: Fri, 9 Jul 2021 16:53:25 -0400 Subject: [PATCH] docs: clarify len and cap attributes for arrays (#10724) --- doc/docs.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/docs.md b/doc/docs.md index 98ee2ceb99..c29dc01323 100644 --- a/doc/docs.md +++ b/doc/docs.md @@ -637,11 +637,11 @@ println(nums) // `[1, 5, 3]` ``` #### Array Properties There are two properties that control the "size" of an array: -* `len`: *length* - the number of defined elements of the array -* `cap`: *capacity* - the number of elements for which memory space has been reserved. The array can -grow up to this size without being reallocated. Usually, V takes care of -this property automatically but there are cases where the user may want to do manual -optimizations (see [below](#array-initialization)). +* `len`: *length* - the number of pre-allocated and initialized elements in the array +* `cap`: *capacity* - the amount of memory space which has been reserved for elements, +but not initialized or counted as elements. The array can grow up to this size without +being reallocated. Usually, V takes care of this property automatically but there are +cases where the user may want to do manual optimizations (see [below](#array-initialization)). ```v mut nums := [1, 2, 3] @@ -1333,7 +1333,7 @@ When an identifier is just a single underscore, it is ignored. ##### Custom iterators Types that implement a `next` method returning an `Option` can be iterated -with a `for` loop. +with a `for` loop. ```v struct SquareIterator {