operator [] method
- int index
Retrieves the element at the specified index.
Guarantees memory safety by throwing a RangeError if index is out of bounds.
Implementation
T operator [](int index) {
if (index < 0 || index >= _data.length) {
throw RangeError.index(index, _data, 'Index out of bounds');
}
return _data[index];
}