lastOrOption method

  1. @override
Option<T> lastOrOption()

Consumes the iterator and returns the last element.

Implementation

@override
Option<T> lastOrOption() {
  if (moveNext()) {
    var last = current;
    while (moveNext()) {
      last = current;
    }
    return Some(last);
  }
  return None;
}