associative array definition
bearophile
bearophileHUGS at lycos.com
Fri Jul 11 14:34:35 PDT 2008
llee:
> But I would like to use a static declaration like the one above.
I suggest you to use the d.learn group for this kind of questions.
I think you can't define AAs statically, but you can do something like:
string[char] map;
static this() {
map = ['a':"foo"[], 'b':"bar"];
}
the static this() is executed before the main().
----------------
Note for the other people, static AAs (and static sets, if D will ever have them) can enjoy perfect hashing, this is a recent note of mine:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/09363c0d50a804bb#
Bye,
bearophile
More information about the Digitalmars-d
mailing list