Untitled
# test
g
Untitled
a
I guess you could keep it that way, or do
if(firstName?.isNotEmpty == true)
Or you could add an extension such as
Copy code
fun String?.isNotNullOrEmpty(): Boolean {
    return !this.isNullOrEmpty()
}
If you just want it to be more verbose
t
You could just put each component in a list and then filter/map over it
so something like:
Copy code
val parts = listOf(firstName, middleInitial, lastName)
return parts
   .filter { it.isNotBlank() }
   .map { it.trim() }
   .joinToString(" ")
g
The filter/map remembers me JS.
How about the testing part? Because I don’t have
else {}
jacoco complains about missing cases.
If I go the filter/map approach, need to see if that improved coverage
thanks kotliners