On Friday, 26 January 2024 at 11:38:39 UTC, Stephen Tashiro wrote:
On Thursday, 25 January 2024 at 20:36:49 UTC, Kagamin wrote:
On Thursday, 25 January 2024 at 20:11:05 UTC, Stephen Tashiro
wrote:
void main()
{
ulong [3][2] static_array = [ [0,1,2],[3,4,5] ];
static_array[2][1] = 6;
}
The static array has length 2, so index 2 is out of bounds,
must be 0 or 1.
I understand that the index 2 is out of bounds in an array of 2
things. I'm confused about the notation for multidimensional
arrays. I thought that the notation uint[m][n] is read from
right to left, so it denotes n arrays of m things in each
array. So I expected that static_array[k][j] would denotes the
kth element of the jth array.
I think the way it actually works is very intuitive, it goes from
inner to outer. If it went the other way around, you couldn't do
this:
```d
void main() {
import std.stdio;
alias point = int[2];
point[3] points = [[0, 0], [1, 2], [3, 4]];
writeln(points);
}
```