operator []= method

  1. @override
void operator []=(
  1. int index,
  2. E value
)

Sets the value at the given index in the list to value or throws a RangeError if index is out of bounds.

A DuplicateValueError will be thrown if the list already contains value, unless the element being set is the equivalent of value.

Implementation

@override
void operator []=(int index, E value) {
  if (elements[index] != value && _contains(value)) {
    throw DuplicateValueError(value);
  }
  elements[index] = value;
}