Created
November 14, 2019 19:22
-
-
Save danbills/8afa10d5cb11c2885f0b2a8fa9ea1160 to your computer and use it in GitHub Desktop.
fold option in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private <T, U> Optional<U> foldOption(Optional<T> option, Function<T,U> f, Supplier<U> ifNone) { | |
return Optional.<U>of(option.map(f).orElse(ifNone.get())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment