Error with associative array initializer DMD32 D Compiler v2.070.0
Anonymouse via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Mar 3 02:23:06 PST 2016
On Thursday, 3 March 2016 at 10:01:47 UTC, MGW wrote:
> immutable long[string] aa = [
> "foo": 5,
> "bar": 10,
> "baz": 2000
> ];
>
> ... Error: non-constant expression ["foo":5L, "bar":10L,
> "baz":2000L]
I'm not sure there's a way around this except by initialising it
at runtime. So you can't get it in the rom segment.
immutable long[string] aa;
shared static this() {
aa = [
"foo": 5,
"bar": 10,
"baz": 2000
];
}
More information about the Digitalmars-d-learn
mailing list