Associative array mapping strings to strings
    Andrew Madigan 
    amadigan at gmail.com
       
    Fri Apr 14 19:41:45 PDT 2006
    
    
  
There was a post about this earlier, but I can't seem to find an answer. How
do I create an associate array mapping strings to strings?
I've tried:
char[][char[]] strings;
----------------
alias char[] string;
string[string] strings;
Which are of course equivalent. Putting strings into the array is not a
problem, however, when I try to retrieve elements I get the following
compiler errors:
(Code:)
char[] headerNames = strings.keys;
for (int i = 0; i < headerNames.length; i++)    {
        writefln("%s: %s", headerNames[i], strings[headerNames[i]]);
}
(Errors:)
TestApp.d:9: cannot implicitly convert expression (_aaKeys(strings,8)) of
type char[][] to char[]
TestApp.d:11: cannot implicitly convert expression (headerNames[i]) of type
char to char[]
This is gdc 0.17, based on dmd 0.14. I'm trying to compile the 0.18 alpha
but it's failing (I'll post about that on the appropriate forum). Is there
something wrong with the declaration? Is there a declaration that works?
    
    
More information about the Digitalmars-d-learn
mailing list