odd result from writefln on int[][]

Bradley Smith digitalmars-com at baysmith.com
Tue Apr 10 01:11:45 PDT 2007


Why does the writefln of [[1,2,3],[4,5,6]] print [[1,2,3],3]?

import std.stdio;

// Ouput:
// [1,2,3] [4,5,6]
// [[1,2,3],3]
void main() {
   int[][] iaa;
   int[] ia1;
   ia1 ~= 1;
   ia1 ~= 2;
   ia1 ~= 3;
   iaa ~= ia1;

   int[] ia2;
   ia2 ~= 4;
   ia2 ~= 5;
   ia2 ~= 6;
   iaa ~= ia2;

   foreach (a; iaa) {
     writef(a, " ");
   }
   writefln();

   writefln(iaa);
}


More information about the Digitalmars-d-learn mailing list