Doc example for Sink.head (#28782)

This commit is contained in:
B YI 2020-03-23 21:03:09 +08:00 committed by GitHub
parent 2cccfa3c29
commit 1545f3fb25
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 0 deletions

View file

@ -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));