How do you add an entry to a map?

dj_d

Member
Specifically, I have a map of records; I'd like to create an entry in the map but not actually initialize the record. Then, later, I'll iterate over the map and populate the values. Is there a way to do that? Right now I'm just arbitrarily initializing one of the record's fields, which works but makes the code more confusing. Something like
add_map(my_map[foo]);
would be perfect.
 

jasonharper

Developer
You can create a new instance of a record via new name-of-record-type - this can be followed by a parenthesized list of initial values for the record, but that's optional, if omitted the record will contain default values in every field. So your entry creating loop would have something like:
my_map[foo] = new my_record;
 
Top