How do I create a module-local immutable class object?
bearophile
bearophileHUGS at lycos.com
Fri Sep 9 14:37:26 PDT 2011
Andrej Mitrovic:
> I need to have an object which is initialized only once, so I thought
> I could use immutable for that. But I can't do this:
>
> private class Foo {}
> immutable Foo foo;
>
> static this()
> {
> foo = new Foo;
> }
>
> void main() {}
private class Foo {}
immutable Foo foo1;
static this() {
foo1 = new immutable(Foo);
}
void main() {
auto foo2 = new immutable(Foo);
}
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list