How to declare static compile-time assoc array inside struct?

Andrey saasecondbox at yandex.ru
Mon Aug 13 13:21:45 UTC 2018


On Monday, 13 August 2018 at 11:53:06 UTC, rikki cattermole wrote:
> You must use a module constructor to initialize it.

Tried this:
static this()
{
     Test.DESCRIPTION = [Test.Type.One: "One!", Test.Type.Two: 
"It's Two...", Test.Type.Three: "And... Three!"];
}

struct Test
{
     // ...
}

I have an error: cannot modify immutable expression DESCRIPTION


More information about the Digitalmars-d-learn mailing list