Skip to content

Instantly share code, notes, and snippets.

@mcupak
Created November 11, 2017 05:50
Show Gist options
  • Select an option

  • Save mcupak/f7d0ce1eedf6518f6e824bcc4c2711ac to your computer and use it in GitHub Desktop.

Select an option

Save mcupak/f7d0ce1eedf6518f6e824bcc4c2711ac to your computer and use it in GitHub Desktop.
jshell> Optional.empty().ifPresentOrElse(System.out::println, () -> System.out.println("empty"))
empty
jshell> Optional.of("something").ifPresentOrElse(System.out::println, () -> System.out.println("empty"))
something
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment