Initialization of the Associative arrays
Don
nospam at nospam.com.au
Mon Jul 14 07:11:57 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])
>
> dmd-2.0.16
>
> Thanks
No. You need to tell the compiler that you're using dynamic, not static
arrays. Just add [] after the first entry.
int[string] x = ["11"[]:11, "1":1];
More information about the Digitalmars-d-learn
mailing list