top method

T top()

get the top of the stack without deleting it.

Implementation

T top() {
  if (isEmpty) {
    throw IllegalOperationException(
      'Can\'t use top with empty stack\n consider '
      'checking for size or isEmpty before calling top',
    );
  }
  return _list.last;
}