Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在 D 中创建一个不可变的关联数组?似乎没有办法定义关联数组;只声明一个。
immutable char[][char[]] = ["testk" = "testv", "testk2" = "testv2"];
好吧,您可以在构造函数中定义不可变关联数组的值。
前任。
static immutable int[string] myArray; static this() { myArray["hi"] = 100; }
您可能希望首先使用可变缓冲区并将其分配给不可变缓冲区。
您应该使用“:”而不是“=”。
immutable (char[][char[]]) = ["testk": "testv", "testk2": "testv2"];