What is the syntax for declaring a constant string[char] AA?
问题 The following declaration: const(string[char]) AA1 = [ 'a' : "fkclopel", 'b' : "poehfftw" ]; void main(string args[]){} gives me: C:...\temp_0186F968.d(1,27): Error: non-constant expression ['a':"fkclopel", 'b':"poehfftw"] while it would work with other type kinds. 回答1: You can initialize associative array constants inside a module constructor: const /+ or immutable +/ (string [char]) AA1; static this () { AA1 = [ 'a' : "fkclopel", 'b' : "poehfftw" ]; } import std.stdio; void main () {writeln