Dynamic memory
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 28 10:07:46 PDT 2015
On 7/28/15 12:59 PM, Binarydepth wrote:
> My confusion comes because I declare "int[2][]" and then I use it backwards
This can definitely be confusing.
The way array types work in D is that they are of the form Type[]. This
means that the element of Type[] is Type. When Type is actually another
array, then you have a multi-indexed array.
So in your case, "Type" is "int[2]". This means, each element of the
dynamic array is a 2-element fixed-sized array.
When indexing, it always goes out to in. So nam[0] is the first element
of type int[2], and nam[0][0] is the first integer in that first element.
Hope this helps. While confusing, it's also VERY consistent and logical.
-Steve
More information about the Digitalmars-d-learn
mailing list