Array operations with multidimensional arrays

Marduk via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 19 11:36:50 PST 2016


On Saturday, 19 November 2016 at 17:37:58 UTC, John Colvin wrote:
> On Saturday, 19 November 2016 at 10:20:16 UTC, Marduk wrote:
>> Additionally, I would like to assign 2D sub-arrays of a 3D 
>> array, i.e. something like the following:
>>
>> int[3][2][2] a;
>>
>> a[0] = [[2,2], [2,2]];
>
> You have the dimensions the wrong way around. a is a 2 element 
> array of 2 element arrays of 3 element arrays.
>
> int[3][2][2] a;
> a[0] = [[2,2,2], [2,2,2]];
>
> works fine.

Thanks a lot! Now I get what it means that array declarations are 
read from right to left.


More information about the Digitalmars-d-learn mailing list