Insert an element into an Associative Array ?

ixid nuaccount at gmail.com
Wed Apr 4 12:55:48 PDT 2012


You're trying to append to something that's not an array, you 
haven't set the value part to be an array so you're doing doing 
the same as:

int a;
a ~= 5;

which obviously doesn't work. If you want to append to an 
associative array create it like this:

Node[][bool] test; //Conceptually maybe clearer as Node[] 
test[bool]
Node node;
test[false] ~= node;

Or set them explicitly as other posters have explained if you 
don't want an array of values at a given key.




More information about the Digitalmars-d-learn mailing list