init property

Option<Iterable<T>> init

Return all the elements of a Iterable except the last one. If the Iterable is empty, return None.

Notice: This operation checks whether the iterable is empty at the time when the Option is returned. The length of a non-empty iterable may change before the returned iterable is iterated. If this original iterable has become empty at that point, the returned iterable will also be empty, same as if this iterable has only one element.

Implementation

Option<Iterable<T>> get init {
  if (isEmpty) return const None();
  return some(this.dropRight(1));
}