arrays in DMD V2

steven kladitis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Apr 19 09:14:42 PDT 2014


void main()
{

//int    a0[];
int[] a0;
//int    a1[][];
int[][] a1;
//string a2[][];
string[][] a2;
//string a3[][string];
string[string] a3;
//  string[][string] a3;
// possibly should be above for a3
//string a4[][string][string];
string[][string][string] a4;
//string a4[string][string][string]; is this the same as above????
//int    a5[][string][string][string];
int[][string][string][string] a5;
//int    a6[string][int][string][float];
int[string][int][string][float] a6;
//int    a7[int][int][string];
int[int][int][string] a7;


// how do you initialize each array, what type are they 
multidimensional???
// how do you define all of the above with limits on each 
dimension???

a0  = [1,2,3];
// works
writeln( a0 );

a1  = [ [ 1,2,3 ],[4,5,6]];
// works
writeln( a1 );

a2  = [ ["a","b" ],[ "c","d" ] ];
//works
writeln ( a2 );

a3  = [ "a":"b","c":"d"];
// works
writeln ( a3 );

a4    = [ "a":["b":["c" ]]];
//works
writeln( a4 );

//a5    = [ 1 :["a":["b":["c" ]]]];
// does not work
writeln(a5);

//  pragma(msg, typeof(a0));
//  pragma(msg, typeof(a1));
//  pragma(msg, typeof(a2));
//  pragma(msg, typeof(a3));
//  pragma(msg, typeof(a4));
//  pragma(msg, typeof(a5));
//  pragma(msg, typeof(a6));
//  pragma(msg, typeof(a7));


//a6        = [ 1,["a",1,"b",4.0]];
// does not work
//a6 = ["a": [1: ["b": [4.0: 5]]]];
// does not work
writeln(a6);


//a7 = [ 1,1,"a"];
// does not work
//a7 = [1: 2[:"3"]];
// does not work
writeln(a7);


// in DMD 2.065
// not sure how to initialize 5,6,7



}


More information about the Digitalmars-d-learn mailing list