single property

  1. @override
dynamic get single
override

Returns the only element in the last dimension.

Throws a StateError if this is empty or has more than one element.

Implementation

@override
dynamic get single {
  List<NdArray> lastDimension = extractDimension(numDimensions);

  if (lastDimension.length > 1) {
    throw StateError('Too many elements');
  } else if (lastDimension.isEmpty) {
    throw StateError('Too few elements');
  }

  return lastDimension.single.data.single;
}