Initialization of the Associative arrays
Bill Baxter
dnewsgroup at billbaxter.com
Mon Jul 14 17:07:36 PDT 2008
Stewart Gordon wrote:
> "Don" <nospam at nospam.com.au> wrote in message
> news:g5fmrg$e7o$1 at digitalmars.com...
>> baleog wrote:
>>> Hello,
>>>
>>> Is it a bug that i can't do like this:
>>> int[string] x = ["11":11, "1":1];
> <snip>
>> 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];
>
> If it isn't a bug, it's certainly a design silliness:
> - that array literals take their type from the first element, rather
> than the lowest common denominator
Amen. [1,2,3.0,4] should be treated as an array of doubles.
> - that there aren't static initialisers for AAs as there are for LAs
Yeh, that sucks too. Although I can see it might be tricky to get working.
Also sucks that initializers for structs only work for static structs.
That one doesn't seem like it should be so hard to fix, but there must
be some catch that prevented W. from throwing it in.
--bb
More information about the Digitalmars-d-learn
mailing list