Last active
January 3, 2019 15:43
-
-
Save scottashipp/e6b0007b4b01a3c3638e152584dbcde6 to your computer and use it in GitHub Desktop.
A motivating example for a Java null-conditional
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
// standard java | |
String zipCode = null; | |
if(user != null) { | |
UserAddresses userAddresses = user.addresses(); | |
if(userAddresses != null) { | |
Address billingAddress = userAddresses.billingAddress(); | |
if (billingAddress != null) { | |
zipCode = billingAddress.zipCode(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment