drop

Drop n elements and then pass any subsequent element downstream.

Simple operators

Signature

Source.drop Flow.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
Java
sourceval fiveInts: Source[Int, NotUsed] = Source(1 to 5)
val droppedThreeInts: Source[Int, NotUsed] = fiveInts.drop(3)

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

droppedThreeInts.runForeach(System.out::println, 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