Is there a way to create an immutable associative array in D? There doesn't seem to be a way to define an associative array; only declare one.
immutable char[][char[]] = ["testk" = "testv", "testk2" = "testv2"];
Is there a way to create an immutable associative array in D? There doesn't seem to be a way to define an associative array; only declare one.
immutable char[][char[]] = ["testk" = "testv", "testk2" = "testv2"];
Well you can define the values of an immutable associative array within a constructor.
Ex.
static immutable int[string] myArray;
static this()
{
myArray["hi"] = 100;
}
You may want to use a mutable buffer first and assigning that to the immutable buffer.
You should use ":" instead of "=".
immutable (char[][char[]]) = ["testk": "testv", "testk2": "testv2"];