Multi-dimensional array comes in handy in a lot of situation, it should be implemented as soon as possible.
oh, please, please.
this is needed more then most other addon stuff.
works for me:
fn main() {
a := [1,2,3]
b := [[1,2,3], [4,5,6]]
println(b[1][0])
}
@medvednikov not the unlucky me:
fn main() {
a := [[[1, 2], [3, 4]], [[5, 6], [7, 8]]]
b := [[1, 2], [3, 4]]
println(a[0][0][0]) // not working
println(b[1][0]) //=> 3
}
main.v:7:22: expected `)` but got `[`
6| println(b[0][0])
7| println(a[0][0][0])
^
8| }
Thanks @87Idiot, only 2d arrays seem to work.
Will fix today.
@medvednikov It's still not working?
I would be nice if this case could be handled as well:
mut multi := [][]string
This happens often when I want to generate an array of arrays in i.e. a for loop.
I see in game_of_live example of matrix usage, and set value works new_field[i] [j] =. But if i use matrix in struct it not works.
struct Matrix {
mut:
data [] []f64
}
m.data[x] [y] = v
a.v:14:17: unexpected token: `=`
14| m.data[x] [y] = v
^
Fixed
Most helpful comment
oh, please, please.
this is needed more then most other addon stuff.