althaf
08/26/2021, 7:34 AMval s: Array<LongArray> = Array(5) { LongArray(10) }
println("size" + s[0].size)
is this the only way to get col size ^^Klitos Kyriacou
08/26/2021, 8:25 AMs[0].size
is the number of columns in the first row. Also, note that your initializer, Array(5) { LongArray(10) }
initializes an array of 5 rows, with the first row being a LongArray of 10 columns, and the remaining rows being null.althaf
08/26/2021, 8:28 AMKlitos Kyriacou
08/26/2021, 9:17 AMStephan Schroeder
08/26/2021, 12:09 PMArray(5) { LongArray(it+1) }
generates
[0] [0]
[1] [0][1]
[2] [0] ...[2]
...
[4] [0] ........ [4]nkiesel
08/26/2021, 8:28 PMArray<Array>
is not the same as a matrix because every row can have a different size. You can count the number of "cells" using `s.sumOf { it.size }`which also works (though slightly less efficient than s.size * s[0].size
) for an array where all rows have the same length.althaf
08/27/2021, 3:07 AM