arrays in DMD V2
steven kladitis via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Apr 18 20:51:01 PDT 2014
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
//a6 = [ 1,["a",1,"b",4.0]];
// does not work
//a7 = [ 1,1,"a"];
// does not work
// also how would you do in a foreach?
}
More information about the Digitalmars-d-learn
mailing list