static immutable AAs documentation
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Fri Dec 15 04:21:18 UTC 2017
On Friday, December 15, 2017 03:49:53 Luís Marques via Digitalmars-d wrote:
> The documentation for AAs gives out this example
> (<https://dlang.org/spec/hash-map.html#static_initialization>):
>
> immutable long[string] aa = [
> "foo": 5,
> "bar": 10,
> "baz": 2000
> ];
>
> unittest
> {
> assert(aa["foo"] == 5);
> assert(aa["bar"] == 10);
> assert(aa["baz"] == 2000);
> }
>
> This isn't actually supported:
>
> <https://issues.dlang.org/show_bug.cgi?id=6238>
> <https://issues.dlang.org/show_bug.cgi?id=1578>
>
> Given how long this limitation has persisted, wouldn't it be best
> to remove that section from the documentation?
It should probably just be changed to used a shared static constructor. e.g.
immutable long[string] aa;
shared static this()
{
aa = ["foo": 5,
"bar": 10,
"baz": 2000];
}
since that does work.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list