Arrays

Olli Aalto oaalto at gmail.com
Wed Jan 10 03:47:02 PST 2007


int[2] intArray = [ 1, 2 ];
int[2] intArray2 = [ 1, 2 ];

assert(intArray == intArray2);  // OK

But...

First:

int[2][2] intMatrix = [ [ 2, 2 ], [ 2, 2 ] ];
This wont compile if it's inside for example unittest block.

I have to declare is either static or in the module scope.

Second:

static int[2][2] intMatrix = [ [ 2, 2 ], [ 2, 2 ] ];
static int[2][2] intMatrix2 = [ [ 2, 2 ], [ 2, 2 ] ];

assert(intMatrix == intMatrix2); // Error: Access Violation

Also I get the access violation if I try to print out the matrix:
std.stdio.writefln(intMatrix);

Any ideas what's going on?

Thanks,

O.



More information about the Digitalmars-d-learn mailing list