3 ms·
Why not replace the tenary operator at the end with the method call in the or else block? return Optional.ofNullable(nullableVariable) .map(v::some
by AnyTimeTraveler 7y ago
Why not replace the tenary operator at the end with the method call in the or else block?
return Optional.ofNullable(nullableVariable)
.map(v::someMethodCall)
.orElse(fallbackIfNullMethodCall);
That also looks much easier to understand, at least to me.