https://kotlinlang.org logo
#announcements
Title
# announcements
m

milorad

08/18/2017, 11:04 AM
Hi guys! Is there a way to use expressions with string interpolation? This looks horrible:
Copy code
it.Specification?.let {
                                with(it) {
                                    val mk = (make ?: "")
                                    val md = model ?: ""
                                    "$mk $md"
                                }
                            }
k

karelpeeters

08/18/2017, 11:07 AM
(use ``` for multi-line code)
m

milorad

08/18/2017, 11:09 AM
Thanks!
g

gildor

08/18/2017, 12:45 PM
"${make ?: ""} ${model ?: ""}"
And use
run
instead of
let
+
with
Also, do you really want to get string that contains only space in case of null for specification?
2 Views