Chris Black
10/30/2020, 4:26 PMcreate
function?
fun add(vararg s: String): String =
s.joinToString(" ")
fun create(one: String, two: String, three: String): String {
val m = mapOf(
one to "one case",
two to "two case",
three to "three case",
"" to ""
)
return add(m[one]!!, m[two]!!, m[three]!!)
}
ephemient
11/03/2020, 8:36 PMlistOfNotNull(
"one case".takeIf { one.isNotEmpty() },
"two case".takeIf { two.isNotEmpty() },
"three case".takeIf { three.isNotEmpty() }
).joinToString(" ")
Chris Black
11/03/2020, 10:27 PMtakeIf{ }
Chris Black
11/03/2020, 10:28 PMmarcinmoskala
11/12/2020, 11:25 AMval res = sequence {
if(one.isNotEmpty()) yield("one case")
if(two.isNotEmpty()) yield("two case")
if(three.isNotEmpty()) yield("three case")
}.joinToString(separator = " ")
marcinmoskala
11/12/2020, 11:25 AMbuildList
Chris Black
11/12/2020, 5:12 PM