Assoc array init

Boris Carvajal boris2.9 at gmail.com
Tue Feb 4 08:15:44 UTC 2020


On Tuesday, 4 February 2020 at 07:52:05 UTC, JN wrote:
> int[int] a = [5: 7];
>
> void main()
> {
> }
>
>
> This fails because apparently [5: 7] is a "non-const 
> expression". How? Why?
>
> Yes, I know I can just init in a static this() section, but 
> that feels like a bad workaround.

AFAIK is not implemented.
https://dlang.org/spec/hash-map.html#static_initialization


More information about the Digitalmars-d-learn mailing list