D1: How to declare an Associative array with data

jicman jicman at gmail.com
Wed Sep 4 13:33:02 UTC 2019


Yes, I know.  I am using D1, and I love it. ;-)

Greetings.

I know that I can declare an array with data, ie.

string[] d = ["1","2","three","4];

and this will be done at compiled time.  I want to do the same 
with an associative array., ie.

int[string] MyDigits = ["0" = 0, "1" = 1, "2" = 2];

That does not work.  I also tried,

int[string] MyDigits = ["0" : 0, "1" : 1, "2" : 2];

Nope, it does not work either.  Any thoughts?  thanks.

josé



More information about the Digitalmars-d-learn mailing list