Multi-dimensional fixed arrays

vladde via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Jun 30 13:22:32 PDT 2015


I am pretty surprised, as the following code gives errors.

>void main(){
>    int [1][2] foo;
>
>    foo[0][0] = 1;
>    foo[0][1] = 2;
>    foo[1][0] = 3;
>    foo[1][1] = 4;
>}

Those errors are:
>app.d(5): Error: array index 1 is out of bounds foo[0][0 .. 1]
>app.d(7): Error: array index 1 is out of bounds foo[1][0 .. 1]

Could anyone more experienced than me explain why this is, and 
why not it's "the other way around"?


More information about the Digitalmars-d-learn mailing list