merge method

void merge(
  1. HTStruct other
)

deep copy another struct then merge with this one. only copy the fields that this struct doesn't have.

Implementation

void merge(HTStruct other) {
  for (final key in other._fields.keys) {
    if (key.startsWith(interpreter.lexicon.internalPrefix)) continue;
    if (_fields.containsKey(key)) continue;
    final value = other._fields[key];
    final copiedValue = interpreter.toStructValue(value);
    define(key, copiedValue, override: true, throws: false);
  }
}