Initialization of the Associative arrays

Steven Schveighoffer schveiguy at yahoo.com
Mon Jul 14 07:10:51 PDT 2008


"baleog" wrote
> Hello,
>
> Is it a bug that i can't do like this:
> int[string] x = ["11":11, "1":1];
> Error: cannot implicitly convert expression ("1") of type 
> invariant(char[1u]) to invariant(char[2u])

It's a foolish issue with D and static arrays. (seriously, I must see about 
1 post a week asking why static arrays don't work right, shouldn't this be a 
priority?)

Try this workaround:

int[string] x = ["11"[]:11, "1":1];

-Steve 




More information about the Digitalmars-d-learn mailing list