Trying to understand multidimensional arrays in D

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jan 26 00:50:08 PST 2017


Sorry. I mistyped some of my examples. Obviously dropped some 
news:

auto a = new int[](4);
auto b = new int[][](4);

And the static arrays should be:
int[4] c;
int[][4] d;

And I would also like managed to overlook there is no static 
array in sight here:

auto y = new int[1][2][][](3,4);

The 1 and 2 are not creating static arrays. They are dynamic 
arrays. The following are exactly the same:

auto a1 = new int[](2);
auto a2 = new int[2];

The syntax in a2 is the original syntax for allocating space for 
dynamic arrays. The () was added later.

The point I made about changing the declaration of x remains.


More information about the Digitalmars-d-learn mailing list