removeLastOrNull method

T? removeLastOrNull()

Removes the last element from this mutable list.

Returns that removed element, or throws NoSuchElementException if this list is empty.

Implementation

T? removeLastOrNull() {
  if (isEmpty()) return null;
  return removeAt(lastIndex);
}