doc: clean up array init docs

pull/12266/head
Alexander Medvednikov 2021-10-22 07:23:45 +03:00 committed by GitHub
parent 5b69593766
commit 47313cbf27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -693,13 +693,6 @@ arrays there is a second initialization syntax:
mut a := []int{len: 10000, cap: 30000, init: 3}
```
You can initialize the array by accessing the it variable as shown here:
```v
mut square := []int{len: 6, init: it * it}
// square == [0, 1, 4, 9, 16, 25]
```
This creates an array of 10000 `int` elements that are all initialized with `3`. Memory
space is reserved for 30000 elements. The parameters `len`, `cap` and `init` are optional;
`len` defaults to `0` and `init` to the default initialization of the element type (`0`
@ -729,6 +722,13 @@ for i in 0 .. 1000 {
Note: The above code uses a [range `for`](#range-for) statement and a
[push operator (`<<`)](#array-operations).
You can initialize the array by accessing the `it` variable as shown here:
```v
mut square := []int{len: 6, init: it * it}
// square == [0, 1, 4, 9, 16, 25]
```
#### Array Types
An array can be of these types: