Adding example of headOption operator (#29717)
Co-authored-by: Johan Andrén <johan@markatta.com>
This commit is contained in:
parent
fb1c6ff253
commit
1ff619259f
3 changed files with 42 additions and 0 deletions
|
|
@ -114,6 +114,15 @@ public class SinkDocExamples {
|
|||
// #fold
|
||||
}
|
||||
|
||||
static void headOptionExample() {
|
||||
// #headoption
|
||||
Source<Integer, NotUsed> source = Source.empty();
|
||||
CompletionStage<Optional<Integer>> result = source.runWith(Sink.headOption(), system);
|
||||
result.thenAccept(System.out::println);
|
||||
// Optional.empty
|
||||
// #headoption
|
||||
}
|
||||
|
||||
static void ignoreExample() {
|
||||
// #ignore
|
||||
Source<String, NotUsed> lines = readLinesFromFile();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue