www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - AA.get() problem

reply bearophile <bearophileHUGS lycos.com> writes:
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 03 2011
parent "Nick Sabalausky" <a a.a> writes:
"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.
May 04 2011