bug in doc?

Andrea Fontana nospam at example.org
Thu Mar 14 14:43:50 UTC 2019


On Thursday, 14 March 2019 at 14:22:52 UTC, spir wrote:
> https://dlang.org/spec/hash-map.html#static_initialization:
>
> immutable long[string] aa = [
>   "foo": 5,
>   "bar": 10,
>   "baz": 2000
> ];

If I'm right, you can't use this syntax with global array. Insted 
this works:

void main()
{
   immutable long[string] aa = [
     "foo": 5,
     "bar": 10,
     "baz": 2000
   ];
}

You should init global AAs using static this() { } as explained 
in the same doc

Andrea


More information about the Digitalmars-d-learn mailing list