Setting immutable static data inside a struct in a module constructor?

aliak something at something.com
Sun Mar 3 20:10:14 UTC 2019


Is it possible to initialize static immutable members of a struct 
like you could do for a global immutable one?

immutable string a;
struct Test {
   static immutable string b;
}

shared static this() {
   a = "foo";
   Test.b = "bar";
}

Error: cannot modify immutable expression b


More information about the Digitalmars-d-learn mailing list