According to the official kotlin documentation, the toString() call of a null object returns "null" toString()
I want, that toString() should return an empty string ("") instead. I implemented it with an extension function.
fun Any?.toEmptyStringIfNull() :String {
if (this == null) {
return ""
} else {
return toString()
}
I am wondering if this could be achieved simpler/easier/cleaner and without calling the extension function everytime.
nullable?.toString().orEmpty()
– Peduncle