Trying to understand multidimensional arrays in D
Ivan Kazmenko via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Jan 26 04:49:54 PST 2017
On Thursday, 26 January 2017 at 05:20:07 UTC, Profile Anaysis
wrote:
>> (On the contrary, declarations in C or C++ looks rather
>> unintuitive from this perspective: `T a[4][5][6]` is means
>> that `a` is an array of 4 arrays of 5 arrays of 6 arrays of
>> `T`. Note how we have to read left-to-right but then wrap
>> around the string to get the meaning.)
>
> lol, I don' tknow what the last sentence means. wrap around the
> string? Do you mean look at the variable?
>
> For me the interpretation above is the most logical because it
> is a sequential operation in my mind, if you will. x of y of z
> and the chain can be cut off anywhere and the interpretation
> still be the same.
This means that in `T a[4][5][6]`, the type `T[4][5][6]` is
spread on both sides of the variable name `a`. In the
interpretation,
"`a` is an array of 4 arrays of 5 arrays of 6 arrays of `T`",
note that 4, 5 and 6 are from the right side but T is from the
left side. That's what I meant by wrap around.
More information about the Digitalmars-d-learn
mailing list