method operator []=


  1. reflectable
void operator []=(K key, V value)

Associates the key with the given value.

If the key was already in the map, its associated value is changed. Otherwise the key-value pair is added to the map.

Source

@reflectable void operator []=(K key, V value) {
  if (!hasObservers) {
    _map[key] = value;
    return;
  }

  int len = _map.length;
  V oldValue = _map[key];

  _map[key] = value;

  if (len != _map.length) {
    notifyPropertyChange(#length, len, _map.length);
    notifyChange(new MapChangeRecord.insert(key, value));
    _notifyKeysValuesChanged();
  } else if (oldValue != value) {
    notifyChange(new MapChangeRecord(key, oldValue, value));
    _notifyValuesChanged();
  }
}