Error with associative array initializer DMD32 D Compiler v2.070.0
mahdi via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 3 03:19:15 PST 2016
On Thursday, 3 March 2016 at 10:35:50 UTC, MGW wrote:
> The citation from https://dlang.org/spec/hash-map.html
>
> Static Initialization of AAs
> ----------------------------
>
> immutable long[string] aa = [
> "foo": 5,
> "bar": 10,
> "baz": 2000
> ];
>
> unittest
> {
> assert(aa["foo"] == 5);
> assert(aa["bar"] == 10);
> assert(aa["baz"] == 2000);
> }
>
> Judging by the text, it is static initialization, during
> compilation.
You have to put that definition inside body of a function (a
declaration). it should not be placed inside module's root level
code.
More information about the Digitalmars-d-learn
mailing list