Why are 2-D arrays reversed?
Steven Schveighoffer
schveiguy at gmail.com
Thu Oct 11 13:01:11 UTC 2018
On 10/10/18 6:26 PM, Chris Katko wrote:
> Wait, this IS the same as C, isn't it? So maybe this is just a "new"
> problem for me since I rarely-if-ever use hardcoded arrays...
Yes, I think that is right. The only difference is if you specify a
NON-square array, D requires you specify in the opposite order from how
you will index (as Jonathan said). In C you specify in the same order.
But for square arrays (dynamic or otherwise), I think it works exactly
the same.
To me, the D way is more consistent and easier to explain because of the
consistency. Any time you see T[], whether T is some basic type or an
array itself, then you have an array of Ts. So int[5][4] is an array of
4 int[5]'s
> Maybe my brain is just melting.
It is recovering from using C ;)
-Steve
More information about the Digitalmars-d-learn
mailing list