Search code examples
dassociative-arraydefinitionimmutablearray

How to create an immutable associative array in D


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"];

Solution

  • You should use ":" instead of "=".

    immutable (char[][char[]]) = ["testk": "testv", "testk2": "testv2"];