Static associative arrays?
Serg Kovrov
kovrov at no.spam
Sun Feb 18 17:40:28 PST 2007
Gregor Richards wrote:
> It would be nice to have a static associative array syntax analogous to
> the static array syntax. Something like this perhaps:
>
> char[][char[]] a = [ "a" : "Apple", "b" : "Banana", "c" : "Cantelope",
> ... ];
>
> This syntax is unambiguous (though admittedly complex) even for
> arbitrarily complex AAs:
>
> char[int][char[][char[]]] a = [ [ "a" : "b", "c" : "d" ] : [ 0 : 'e', 1
> : 'f' ] ];
>
> It also has the added advantage of being similar to the static struct
> syntax.
Yep, what we need, is sort of 'AA Literals' which can be used to
initialize either static or dynamic associative array.
--
serg.
More information about the Digitalmars-d
mailing list