Struct immutable data and dict

Patric Dexheimer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Oct 5 18:23:35 PDT 2016


struct Test{
     immutable size_t id;
}

Test[string] dict;
Test[] array;

void main(){
     array~=Test(1);//work
     dict["teste"] = Test(1); //fail ??
}

"Error: cannot modify struct dict["teste"] Test with immutable 
members"
Why?


More information about the Digitalmars-d-learn mailing list