drop

Drop n elements and then pass any subsequent element downstream.

Simple operators

Signature

Source.dropSource.drop Flow.dropFlow.drop

Description

Drop n elements and then pass any subsequent element downstream.

Example

Given a Source of numbers we can drop the first 3 elements with the drop operator:

Scala
val fiveInts: Source[Int, NotUsed] = Source(1 to 5)
val droppedThreeInts: Source[Int, NotUsed] = fiveInts.drop(3)

droppedThreeInts.runForeach(println)
// 4
// 5
Java
Source<Integer, NotUsed> fiveIntegers = Source.from(Arrays.asList(1, 2, 3, 4, 5));
Source<Integer, NotUsed> droppedThreeInts = fiveIntegers.drop(3);

droppedThreeInts.runWith(Sink.foreach(System.out::print), system);
// 4
// 5

Reactive Streams semantics

emits when the specified number of elements has been dropped already

backpressures when the specified number of elements has been dropped and downstream backpressures

completes when upstream completes

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.