static initialization of associative arrays
Tyro[a.c.edwards]
nospam at home.com
Wed Apr 15 03:51:40 PDT 2009
Is it yet possible to statically initialize an associative array? If so,
please point me to the documentation. I am using DMD v2.028.
Currently I'm able to do this:
import std.stdio;
string[string] types;
static this(){
types = [ "void":"void", "bool":"bool" ];
}
void main(){
writeln(types);
}
Output = [void:void,bool:bool] which is exactly what I want.
However, removing static this() results in an error.
string[string] types = [ "void":"void", "bool":"bool" ];
Result:
api.d(77): Error: non-constant expression ["void":"void","bool":"bool"]
How do I make the initialization constant?
Thanks,
Andrew
More information about the Digitalmars-d-learn
mailing list