www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - odd result from writefln on int[][]

reply Bradley Smith <digitalmars-com baysmith.com> writes:
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);
}
Apr 10 2007
parent Bill Baxter <dnewsgroup billbaxter.com> writes:
Bradley Smith wrote:
 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);
 }

Bug 1000, (or 999 -- I forget which). --bb
Apr 10 2007