Cannot initialize associative array.
Bernard Helyer
b.helyer at gmail.com
Tue Jun 22 15:01:40 PDT 2010
On Tue, 22 Jun 2010 21:32:48 +0000, dcoder wrote:
> Sorry, I forgot to put some compiler output:
>
> For the declaration: uint[string] mywords = [ "Hello" : 1, "World" : 1,
> "Cat" : 1, "Dog" : 1 ];
>
>
> I get:
>
> $ dmd test_01.d
> test_01.d(3): Error: non-constant expression
> ["Hello":1u,"World":1u,"Cat":1u,"Dog":1u]
AAs can't be assigned to at compile time (:[). You'll have to use a
static constructor or an initiliasation function to assign to one at
global scope.
More information about the Digitalmars-d-learn
mailing list