skip

inline fun <T> Iterable<T>.skip(numberToSkip: Int): Iterable<T>(source)

Returns a view of this that skips its first numberToSkip elements. If this contains fewer than numberToSkip elements, the returned iterable skips all of its elements.

Modifications to the underlying Iterable before a call to iterator() are reflected in the returned iterator. That is, the iterator skips the first numberToSkip elements that exist when the Iterator is created, not when skip is called.

Stream equivalent: Stream.skip

See also


@JvmName(name = "skipMutable")
inline fun <T> MutableIterable<T>.skip(numberToSkip: Int): Iterable<T>(source)

Returns a view of this that skips its first numberToSkip elements. If this contains fewer than numberToSkip elements, the returned iterable skips all of its elements.

Modifications to the underlying Iterable before a call to iterator() are reflected in the returned iterator. That is, the iterator skips the first numberToSkip elements that exist when the Iterator is created, not when skip is called.

The returned iterable's iterator supports remove() if the iterator of the underlying iterable supports it. Note that it is not possible to delete the last skipped element by immediately calling remove() on that iterator, as the MutableIterator contract states that a call to remove() before a call to next() will throw an IllegalStateException.

Stream equivalent: Stream.skip

See also