If it makes sense to avoid returning null from the function in the first place, I'd consider that first. For instance, if
true
makes sense as a default value for
func2call
, it'd be better if it returned
true
instead of null.
If that doesn't make sense (if it's useful to distinguish null from true), then you could express the default with the elvis operator at the call site:
val exitProcessing = func2call(tId, fId) ?: true
if (exitProcessing) return
Or directly return from elvis in addition to the `if`:
val exitProcessing = func2call(tId, fId) ?: return
if (exitProcessing) return
Although that one might be harder to read/understand