So how do you create an associative array with an immutable value, anyways?

FeepingCreature feepingcreature at gmail.com
Fri Oct 7 06:58:32 UTC 2022


`assocArray` famously complains that it needs a mutable value 
type. You can't set values. You could write a literal, but that 
only works for a finite number of keys, and there's no way to 
merge two associative arrays.

Internally, we use librebindable, so we can create a 
`Rebindable!(immutable V)[K]`, which is mutable, and cast it to 
`immutable V[K]` without breaking anything. But I'm not sure how 
I'd propose getting that into Phobos without including 
librebindable outright. But I also don't see another way to do it?

Any ideas?


More information about the Digitalmars-d mailing list