firstOptional property

Optional<T> get firstOptional

The first element, or Optional.empty() if the iterable is empty.

Implementation

Optional<T> get firstOptional {
  var iterator = this.iterator;
  if (iterator.moveNext()) return Optional.of(iterator.current);
  return Optional.empty();
}