3 ms·
Surprised that guard clauses weren't mentioned here yet, you could also write ``` if (account == null) { throw NoAccountException } if (account.contact ==
by return_to_monke 4y ago
Surprised that guard clauses weren't mentioned here yet, you could also write
```
if (account == null) {
throw NoAccountException
}
if (account.contact == null) {
throw AccountWithoutContactException
}
if (account.contact.phoneNumber == null) {
throw ContactWithoutPhoneNumberException
}
// do stuff here
```
- commandlinefan 4y agoThat would be way better, but I've never seen it.