Multidimensional array access

somebody via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Dec 20 11:59:41 PST 2016


I though D should have syntax similarities with C, but recently 
I've found that array indexing in D is different. Suppose we have 
a code:

import std.stdio;

void main ()
{
     wstring[6][2] strings;
     strings[2][0] = "test";
}


It fails to compile because of error:

"./main.d(6): Error: array index 2 is out of bounds strings[0 .. 
2]"

Why? There should be 6 rows and 2 columns, but it seems that it's 
the opposite. Am I misunderstood something or is it a bug?




More information about the Digitalmars-d-learn mailing list