1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

doc: 2d array example (#6058)

This commit is contained in:
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

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