Last active
February 17, 2022 14:16
-
-
Save zivce/f101538b7d6309870d74a9b561706027 to your computer and use it in GitHub Desktop.
How to not create ifNotPresent in Java
This file contains hidden or 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
Optional.of(opt).map(value -> { System.out.println(value); | |
return value; }) | |
.orElseGet(() -> { System.out.println("not present"); | |
return -1;}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment