operator []= method Null safety
- int index,
- dynamic newVal
Implementation
operator []=(int index, newVal) {
if (index == 0) {
item1 = newVal;
} else if (index == 1) {
item2 = newVal;
} else if (index < 0) {
this[(index % 2)] = newVal;
}
throw RangeError('$index is out of range (only 1 and 2)');
}