String append with Null Check Kotlin
What would be ideomic way to append String with NULL check? Perhaps this is stupid question, but I am curious to know the best way.
I tried these-
fun main(args: Array) {
val foo: String? = null
val bar = "bar"
println("__println(\"\$foo \$bar\")")
println("$foo $bar")
println("__println((if (foo != null) \"\$foo \" else \"\") + (if (bar != null) \"\$bar \" else \"\"))")
println((if (foo != null) "$foo " else "") + (if (bar != null) "$bar " else ""))...