martmists
07/25/2022, 10:54 AMsomeFunction( // takes varargs
*arrayOf(if (condition) "someValue" else null).filterNotNull().toTypedArray(),
)
wbertan
07/25/2022, 10:55 AMlistOfNotNull
?ephemient
07/25/2022, 11:08 AMsomeFunction(
*if (condition) arrayOf("someValue") else emptyArray()
)
Klitos Kyriacou
07/25/2022, 11:12 AMif (condition)
someFunction("someValue")
else
someFunction()
Alan B
07/25/2022, 1:08 PMfun anotherFunction(condition: Boolean) =
if (condition)
arrayOf("someValue")
else
emptyArray()
At least then the “condition” is now testable alone, as it would have been buried in the call of another function and therefore obfuscated.
someFunction(*anotherFunction(condition))