2-D array initialization

Andy Balba pwplus7 at gmail.com
Fri Jul 31 23:42:45 UTC 2020


ubyte[3][4] c ;

How does one initialize c in D ?  none of the statements below 
works

  c = cast(ubyte) [ [5, 5, 5], [15, 15,15], [25, 25,25], [35, 
35,35]  ];

c[0] = ubyte[3] [5, 5, 5]   ;  c[1] = ubyte[3] [15, 15,15] ;
c[2] = ubyte[3] [25, 25,25] ;  c[3] = ubyte[3] [35, 35,35] ;

for (int i= 0; i<3; i++) for (int j= 0; i<4; j++) c[i][j]= 
cast(ubyte)(10*i +j) ;


More information about the Digitalmars-d-learn mailing list