Rajkumar Singh
01/20/2022, 10:55 PMval exitProcessing: Boolean? = func2call(tId, fId)
if (exitProcessing == null || exitProcessing == true) return
Joffrey
01/20/2022, 11:01 PMtrue
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/understandephemient
01/20/2022, 11:29 PMexitProcessing != false
is preferred over
exitProcessing ?: true
by the style guide: https://kotlinlang.org/docs/idioms.html#nullable-booleanJoffrey
01/20/2022, 11:34 PMif (exitProcessing ?: true)
would feel weird. Here I'm suggesting using elvis for the variable assignment, not in the conditionRajkumar Singh
01/20/2022, 11:57 PM