static init of associative array of enums not working.. why?
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Feb 26 20:35:41 PST 2016
On Saturday, 27 February 2016 at 04:15:06 UTC, Øivind wrote:
> Shouldn't this work? According to "Static Initialization of
> AAs" on this page, it should:
> https://dlang.org/spec/hash-map.html
It just isn't implemented in the compiler. Instead, you can
declare it outside and set it in a static module constructor:
immutable DevicePropDataType[DevicePropValType] propDType;
shared static this() {
propDType =
[
DevicePropValType.property:
DevicePropDataType.dString,
DevicePropValType.miscDate:
DevicePropDataType.dDateTime
];
}
void main() {
}
More information about the Digitalmars-d-learn
mailing list