orEmpty
Returns the string if it is not null, or the empty string otherwise.
inline fun String?.orEmpty(): String(source)
val maybeName: String? = null
val name = maybeName.orEmpty() // name == ""
val greeting = "Hello, ${maybeName.orEmpty()}!"
Returns the string if it is not null, or the empty string otherwise.
inline fun String?.orEmpty(): String(source)
val maybeName: String? = null
val name = maybeName.orEmpty() // name == ""
val greeting = "Hello, ${maybeName.orEmpty()}!"