Method code for $dictionary.add_elem()

[Turn off line numbering]
  1: arg dict, key, elem;
  2: var value;
  3: 
  4: // Add an element to the list value of a dictionary key
  5: value = (| dict[key] |);
  6: if (type(value) != 'list && type(value) != 'error)
  7:     throw(~type, "Value for key " + key + " (" + value + ") is not a list.");
  8: anticipate_assignment();
  9: if (value) {
 10:     // reduce references to 'value'
 11:     dict = dict_add(dict, key, 0);
 12:     value += [elem];
 13: } else {
 14:     value = [elem];
 15: }
 16: return dict_add(dict, key, value);

// Created 27-Mar-1995 as a part of ColdCore, see: @help Credit

Tlon