Associative array of const items

Jonathan Marler via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 30 10:08:45 PDT 2016


Is there a way to have an associative array of const values? I 
thought it would have been:

const(T)[K] map;
map[x] = y;

but the second line gives Error: cannot modify const expression.  
I would think that the const(T)[K] would behave similarly to 
const(T)[], where you can modify the array, just not the 
individual elements, but associative arrays don't seem to have 
the same semantics.  Is there a way to achieve these semantics 
with an associative array?







More information about the Digitalmars-d-learn mailing list