Cannot initialize associative array.
pelle.mansson at gmail.com
Wed Jun 23 02:35:28 PDT 2010
On 06/23/2010 09:41 AM, Ali Çehreli wrote:
> Ali Çehreli wrote:
>> dcoder wrote:
>> > So, I moved the initialization to inside the main function, and now
>> it works.
>> > Great. I think we need to put this question in the FAQ.
>> For future reference, if it really needs to be global:
>> uint[string] mywords;
>> static this()
>> mywords = [ "Hello" : 1, "World" : 1, "Cat" : 1, "Dog" : 1 ];
> Could someone please verify whether the above is really necessary? Is it
> actually a dmd bug that we need to use 'static this()' to initialize an
> associative array?
I say it's a bug, a literal like that should be a constant expression.
Someone report it!
More information about the Digitalmars-d-learn