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

Seb seb at wilzba.ch
Mon Aug 13 14:48:17 UTC 2018


On Monday, 13 August 2018 at 13:21:45 UTC, Andrey wrote:
> 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

What is your other code?

It can work, e.g.:

https://run.dlang.io/is/kAC4pl


More information about the Digitalmars-d-learn mailing list