5 ms·
Even that seems way too much. The original would be much easier as: if (nullableVariable != null) { boolean success = nullableVariable.someMethodCall()
by arnvidr 7y ago
Even that seems way too much. The original would be much easier as:
if (nullableVariable != null) {
boolean success = nullableVariable.someMethodCall()
if (success) {
return success;
}
}
return fallbackIfNullMethodCall();
And even that can be more concise if you prefer:
if (nullableVariable != null && nullableVariable.someMethodCall()) {
return true;
}
return fallbackIfNullMethodCall();
- nimchimpsky 7y agoWhy isn't anyone using the ternary operator ? return (nullableVariable != null && nullableVariable.someMethodCall()) ? true : fallbackIfNullMethodCall();