Doubt - Static multidimension arrays

tsbockman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 18 23:32:22 PST 2016


On Tuesday, 19 January 2016 at 07:21:39 UTC, albert00 wrote:
> Again seems a bit strange "FOR ME" since I declare in one way 
> and access the other way.
>
> albert.

That's because you're stuck in the mindset that 2d arrays are 
somehow *special*. If I do this:

Row[5] a;
const b = a[4];

Of what type do you expect `b` to be? Of type `Row`, yes?

Now let's define `Row`:

alias Row = int[10];
Row[5] a;
const b = a[9];
const int = c = b[4];

Of what type is `b` now? Of course it is still `Row`.

By substitution, we expect `b[0]` to be equal to `(a[9])[4]`.


More information about the Digitalmars-d-learn mailing list