Rang violation using AA's

Nrgyzer nrgyzer at unknownMailAddress.com
Fri Feb 8 09:16:14 PST 2013


Hi guys,

I'm updated from DMD 2.060 to 2.061 and I just run into some 
trouble by using associative arrays. Let's say I've the following 
few lines:

string[string] myValues;

ref string getValue(string v) {
    return myValues[v];
}

void main() {
    getValue("myValue") = "myString";
}

I get a range violation in getValue() because the entry does not 
exist. But as far as I know, this worked in 2.060 (no range 
violation). One idea was to initialize the value in getValue() if 
it does not exist, but my associative array looks like:

string[string][][string] myValues;

... how to initialize this? So, is this a bug or is it my mistake?


More information about the Digitalmars-d-learn mailing list