Initialize associate array

pham via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 29 13:03:46 PST 2016


Should codes below be compiled?

import std.stdio;

class Test
{
	enum string[string] WorkAA =
	[
		"foo": "work"
	];

	immutable string[string] NotWorkAA1 =
	[
		"foo": "not work"
	];

	string[string] NotWorkAA2 =
	[
		"foo": "not work"
	];
}

void main()
{
	Test t = new Test();	
}

Test with DPaste with below error messages

Result: Compilation error / Return code: 1 (Hangup)
Compilation output:

/d699/f49.d(11): Error: non-constant expression ["foo":"not work"]
/d699/f49.d(16): Error: non-constant expression ["foo":"not work"]



More information about the Digitalmars-d-learn mailing list