Doc example for Sink.head (#28782)
This commit is contained in:
parent
2cccfa3c29
commit
1545f3fb25
3 changed files with 28 additions and 0 deletions
|
|
@ -78,6 +78,15 @@ public class SinkDocExamples {
|
|||
// #takeLast-operator-example
|
||||
}
|
||||
|
||||
static void headExample() {
|
||||
// #head-operator-example
|
||||
Source<Integer, NotUsed> source = Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
CompletionStage<Integer> result = source.runWith(Sink.head(), system);
|
||||
result.thenAccept(System.out::println);
|
||||
// 1
|
||||
// #head-operator-example
|
||||
}
|
||||
|
||||
static void lastExample() {
|
||||
// #last-operator-example
|
||||
Source<Integer, NotUsed> source = Source.from(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue