operator [] method

dynamic operator [](
  1. int index
)

Returns the value at index.

Throws a RangeError if index is out of bounds.

Implementation

dynamic operator [](int index) {
  _checkRange(index);

  if (numDimensions == 1) {
    return _data[index];
  }

  final NdArray ndArray = NdArray(numDimensions - 1);

  if (_data[index] is List) {
    ndArray._data = _data[index];
  } else {
    ndArray._data = [_data[index]];
  }

  return ndArray;
}