www.digitalmars.com         C & C++   DMDScript  

D - [bug] assoc array lookup

[bug] assoc array lookup

set: m[key] = value
get: value = m[key]

both set and get,same function is called.(aaGet in phobos/internal/aaA.d)
so when lookup undefined key,
m[key] = null(or 0 cleared) entry is created.

test program:

import std.string;

int main(char [][] argv)
{
char[][char[]] m;
m["AA"] = "b";
m["AB"] = "c";
printf("%d\n",m.length);
printf("%s %s\n",toStringz(m["AA"]),toStringz(m["AB"]));
char[] s = m["AC"];
printf("%d\n",m.length);

return 0;
}
Jan 17 2004