Peter Lundgren:

> If not, then what is the D way to initialize a static field of a struct or 
> class a
> la Java's static initializer blocks? I don't mind constructing the associative
> array at run-time if I have to, but I can't afford to do it more than the 
> once needed.

Is this good enough?

struct Foo {
    static int[int] aa;
    static this() {
        aa[0] = 1;
    }
}

void main() {
    assert(Foo.aa[0] == 1);
}

Bye,
bearophile

Reply via email to