immutable and static this()

teo teo.ubuntu at yahoo.com
Mon Mar 21 14:27:17 PDT 2011


I cannot initialize immutable class members inside a static this() 
constructor. Is there any reason for that?

Example:
class Test
{
    public immutable(int) x;
    static this()
    {
        x = 1; // Error: variable Test.x can only initialize const x 
inside constructor
    }
}


More information about the Digitalmars-d-learn mailing list