このページはまだ翻訳されていないため、英語で表示されます。 翻訳に参加する

dropRight

Returns a lazy iterable that omits the last length values.

Iterable<A> dropRight<A>(int length, Iterable<A> iterable) FxAsyncIterable<A> dropRightAsync<A>(int length, FxAsyncIterable<A> iterable) Fx<T> Fx.dropRight(int count) // chain FxAsync<T> FxAsync.dropRight(int count)

Lecture

dropRight omits the last length values instead of the first. As with takeRight, there's no way to know which elements are "last" without seeing the whole source, so dropRight materializes it into a list before yielding anything. It's the right tool when you have, say, a known-size batch and want everything except a trailing footer or sentinel — but it needs a finite source.

dropRightAsync carries the same constraint: it awaits the entire upstream before it can start producing values.

Demo 1 · Basics

Demo 2 · Async (must buffer the whole source first)

Try it yourself

Exercise: drop the last 2 footer lines.

Related: drop — drop from the front instead · takeRight — keep the last n instead of dropping them · reverse — also materializes the source