Created
March 14, 2020 04:01
-
-
Save ashkrit/035ed317b3f2f14d5f81c17c75b07f06 to your computer and use it in GitHub Desktop.
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
| //Don't do this | |
| System.out.println("Calling Phone " + phone.get()); | |
| System.out.println("Sending Email " + email.get()); | |
| //Use ifPresent to avoid runtime error | |
| phone.ifPresent(contact -> System.out.println("Sending email to " + contact)); | |
| email.ifPresent(contact -> System.out.println("Calling " + contact)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment