On 5-12-2010 19:20, Matthias Walter wrote:

The only thing I've been able to think of is

    byte[][] a;
    a.length = size;
    for (int i; i<  size; i++) {
         a[i].length = size;
    }
Well, you can do at least:

auto a = new byte[][size];
foreach (ref row; a)
   row = new byte[size];

That works.

So I can write

   byte[] a = new byte[size];

and

   byte[][] a = new byte[][size];

but not

   byte[][] a = new byte[size][];

or

   byte[][] a = new byte[size][size];

let alone

   byte[size][size] a;


BTW, somebody on stackoverflow just posted an alternative
that comes closest to what I was looking for.

   byte[][] a = new byte[][](size, size);

I saw this notation before but I can't remember where.

Hey, I love D but it can be pretty confusing sometimes :)

Thanks

Reply via email to