On Saturday, 19 April 2014 at 03:51:02 UTC, steven kladitis wrote:
import std.stdio;


void main()
{

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

// 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];
//writefln( a0 );

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

a2  = [ ["a","b" ],[ "c","d" ] ];

//writefln ( a2 );

//a3  = [ ["a","b" ],[ "c","d" ] ];
// does not work

//a4    = [ ["a","b" ];
// does not work.

//a5      = [ [1,"a","b"]];

  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));
//  does not work

Works for me.

a6 = int[float][string][int][string]
a7 = int[string][int][int]


//a6        = [ 1,["a",1,"b",4.0]];
// does not work

a6 = ["a": [1: ["b": [4.0: 5]]]];
writeln(a6["a"]);


//a7 = [ 1,1,"a"];
// does not work

a7 = [1: [2: ["3": 4]]];

// also how would you do in a foreach?

foreach is for getting values out.

a0 ~= 7 // Append 7 to array
int[string] a8;
a8["hello"] = 6; // Add six to a8 for "hello"
assert(a8["hello"] == 6);

Reply via email to