zipWithIndex
Zips elements of current flow with its indices.
Signature¶
Source.zipWithIndex
Flow.zipWithIndex
Description¶
Zips elements of current flow with its indices.
See also:
Example¶
sourceimport org.apache.pekko
import pekko.stream.scaladsl.Source
import pekko.stream.scaladsl.Sink
Source(List("apple", "orange", "banana")).zipWithIndex.runWith(Sink.foreach(println))
// this will print ('apple', 0), ('orange', 1), ('banana', 2)
sourceimport org.apache.pekko.stream.javadsl.Keep;
import org.apache.pekko.stream.javadsl.Source;
import org.apache.pekko.stream.javadsl.Sink;
import java.util.*;
Source.from(Arrays.asList("apple", "orange", "banana"))
.zipWithIndex()
.runForeach(System.out::println, system);
// this will print ('apple', 0), ('orange', 1), ('banana', 2)
Reactive Streams semantics¶
emits upstream emits an element and is paired with their index
backpressures when downstream backpressures
completes when upstream completes
1.2.0-M1+35-3d489313*