doc: 2d array example (#6058)

pull/6063/head
Maciej Obarski 2020-08-05 01:46:04 +02:00 committed by GitHub
parent df332f85b7
commit 8d9f38f670
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -524,6 +524,24 @@ println(upper) // ['HELLO', 'WORLD']
`it` is a builtin variable which refers to element currently being processed in filter/map methods.
#### Multidimensional Arrays
Arrays can have more than one dimension.
2d array example:
```v
mut a := [][]int{len:2, init: []int{len:3}}
a[0][1] = 2
println(a) // [[0, 2, 0], [0, 0, 0]]
```
3d array example:
```v
mut a := [][][]int{len:2, init: [][]int{len:3, init: []int{len:2}}}
a[0][1][1] = 2
println(a) // [[[0, 0], [0, 2], [0, 0]], [[0, 0], [0, 0], [0, 0]]]
```
### Maps
```v