Skip to content

Instantly share code, notes, and snippets.

@scottashipp
Last active January 3, 2019 15:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottashipp/e6b0007b4b01a3c3638e152584dbcde6 to your computer and use it in GitHub Desktop.
Save scottashipp/e6b0007b4b01a3c3638e152584dbcde6 to your computer and use it in GitHub Desktop.
A motivating example for a Java null-conditional
// 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