Crazy stuff
    Simen Kjaeraas 
    simen.kjaras at gmail.com
       
    Sun Apr 27 06:54:00 PDT 2008
    
    
  
On Sun, 27 Apr 2008 14:58:12 +0200, Tower Ty <tytower at hotmail.com.au>  
wrote:
> I suppose I'm getting tired but this array stuff is just so bloody  
> non-intuiitive
>
> I'm copying an array  of strings into another array of arrays of strings
> char[][] array1
> array1 has in it [ 1, 12/12/06, 0123456, Hubert, 340, 1240.00, 0.00 ]
> and I want to accumulate it in ,
> char[][][] array2
> as a line in array2. Array1's contents will change on the next pass of  
> the loop and I increase x by 1 and want to store it then in array2line2
> So I try
> array2[x]=array1;
> or
> array2[x]=array1[0..6]
> or
> array2[x]=array1[]
> or Jesus I'm buggered if I know what to try next ,it could be anything
>
> array2[x]=array1.dup don't work either
This works on my confuser (DMD 2.013, DMD 1.029):
   string[] a = ["Hello", "World"];
   string[][] b;
   b ~= a.dup;
   a[0] = "HAI";
   a[1] = "WURLD!1";
   b ~= a.dup;
   writefln(b); // prints [[Hello,World],[HAI,WORLD!!!1]]
Without the .dups, output is [[HAI,WORLD!!!1],[HAI,WORLD!!!1]].
-- Simen
    
    
More information about the Digitalmars-d-learn
mailing list