multi-dimensional array whole slicing

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 25 13:46:24 PDT 2017


On 04/23/2017 12:04 PM, XavierAP wrote:

 > For both multi-dimensional and
 > uni-dimensional arrays a[] and a[][] are the same. And yet, a[] has
 > different type in both cases and a[]=1 compiles for uni-dimensional but
 > not for multi-dimensional.

I think it's still consistent because the element type is not int in the 
case of multi-dimensional arrays. The following makes sense to me but I 
haven't profiled it. Otherwise, kinke's solution is perfectly fine in a 
system programming language. ;)

     int[3] a;
     a[] = 1;
     a[][] = 1;  // Same effect

     int[3][4] b;
     b[] = [1, 1, 1];
     b[][] = [1, 1, 1];  // Same effect

Ali



More information about the Digitalmars-d-learn mailing list