How do I create a module-local immutable class object?

Timon Gehr timon.gehr at gmx.ch
Fri Sep 9 14:42:55 PDT 2011


On 09/09/2011 11:36 PM, Andrej Mitrovic wrote:
> Ok it seems using const works, so I can use that instead. Still I'm
> wondering why I can't initialize foo inside a module ctor.

It works for const because mutable is implicitly convertible to const, 
but not to immutable. You have to allocate an immutable class instance 
to make it work.

foo = new immutable(Foo);


More information about the Digitalmars-d-learn mailing list