doc: document array.clone()
parent
ecfd124390
commit
b9bf7a6583
10
doc/docs.md
10
doc/docs.md
|
@ -534,8 +534,7 @@ The type of an array is determined by the first element:
|
|||
* `[1, 2, 3]` is an array of ints (`[]int`).
|
||||
* `['a', 'b']` is an array of strings (`[]string`).
|
||||
|
||||
If V is unable to infer the type of an array,
|
||||
the user can explicitly specify it for the first element: `[byte(16), 32, 64, 128]`.
|
||||
The user can explicitly specify the for the first element: `[byte(16), 32, 64, 128]`.
|
||||
V arrays are homogeneous (all elements must have the same type).
|
||||
This means that code like `[1, 'a']` will not compile.
|
||||
|
||||
|
@ -595,6 +594,13 @@ Note: The above code uses a [range `for`](#range-for) statement.
|
|||
All arrays can be easily printed with `println(arr)` and converted to a string
|
||||
with `s := arr.str()`.
|
||||
|
||||
Copying the data from the array is done with `.clone()`:
|
||||
|
||||
```v nofmt
|
||||
nums := [1, 2, 3]
|
||||
nums_copy := nums.clone()
|
||||
```
|
||||
|
||||
Arrays can be efficiently filtered and mapped with the `.filter()` and
|
||||
`.map()` methods:
|
||||
|
||||
|
|
Loading…
Reference in New Issue