On Wed, 06 Oct 2010 03:45:11 +0400, bearophile <bearophileh...@lycos.com>
wrote:
/*immutable*/ E_MODE[string] a_mode;
static this () {
foreach (m; __traits(allMembers, E_MODE))
mixin(`a_mode["` ~ m ~ `"] = E_MODE.` ~ m ~ `;`);
}
How do you build an immutable AA that is global or local to a function?
Bye,
bearophile
I found the following to work fine:
K[V] assocArray = createAssocArray();
K[V] createAssocArray()
{
K[V] assocArray = [
k1: v1,
k2: v2,
...
];
return assocArray;
}
No idea why the following:
K[V] assocArray = [
k1: v1,
k2: v2,
...
];
doesn't work directly for global scope.