initializing static rectangular arrays

Janice Caron caron800 at googlemail.com
Sat Nov 17 14:54:11 PST 2007


On 11/17/07, naryl <cy at ngs.ru> wrote:
> You can initialize it like that:
>         float[3][4] elements =
>          [
>             [1.1, 1.2, 1.3],
>              [2.1, 2.2, 2.3],
>              [3.1, 3.2, 3.3],
>              [4.1, 4.2, 4.3]
>          ];

Yes, because D puts the array dimension on the type, not the variable.
(But you can do it the C way if you want).

So
    float elements[4][3];
==
    float[3] elements[4];
==
    float[3][4] elements;

(At least, I think that's right. Disclaimer: I don't have a compiler
handy right now).



More information about the Digitalmars-d mailing list