Fixed matrix rows joining

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Jan 14 18:18:26 PST 2012


A rectangular array is really just one array, is it not? From a syntax
point it looks like a multidimensional array but really it's just a
single linear piece of memory, so just cast it:

void main()
{
    int[2][4] table;
    table[0][] = 0;
    table[1][] = 1;
    table[2][] = 2;
    table[3][] = 3;
    auto x = cast(int[])table;
    assert(x == [0, 0, 1, 1, 2, 2, 3, 3]);
}


More information about the Digitalmars-d-learn mailing list