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.

Reply via email to