May 04, 2011
This gives me compilation errors, is this a bug, or is my code wrong?


import std.stdio;
void main() {
    string[char] tab = ['e': "red", 'b': "blue"];
    string r;
    foreach (c; "aba") {
        // if (c in tab) r ~= tab[c]; // OK
        r ~= tab.get(c, ""); // ERR
    }
    writeln(r);
}


Thank you, bye,
bearophile
May 04, 2011
"bearophile" <bearophileHUGS@lycos.com> wrote in message news:ipq6bd$2211$1@digitalmars.com...
> This gives me compilation errors, is this a bug, or is my code wrong?
>
>
> import std.stdio;
> void main() {
>    string[char] tab = ['e': "red", 'b': "blue"];
>    string r;
>    foreach (c; "aba") {
>        // if (c in tab) r ~= tab[c]; // OK
>        r ~= tab.get(c, ""); // ERR
>    }
>    writeln(r);
> }
>

On DMD 2.052 Win, that just gives me a linker error:

 Error 42: Symbol Undefined
_D6object28__T16AssociativeArrayTaTAyaZ16AssociativeArray3getMFaLAyaZAya

Sounds like a bug to me.