cast<R> method

Iterable<R> cast <R>()

Makes this iterable useful as an Iterable<R>, if necessary.

Like retype except that this iterable is returned as-is if it is already an Iterable<R>.

It means that someIterable.cast<Object>().toList() is not guaranteed to return precisely a List<Object>, but it may return a subtype.

Implementation

Iterable<R> cast<R>() {
  Iterable<Object> self = this;
  return self is Iterable<R> ? self : Iterable.castFrom<E, R>(this);
}