Is there "toStringOrNull"? I want to run toString(...
# getting-started
k
Is there "toStringOrNull"? I want to run toString() to a nullable string but I want to return null if the value was null
l
variable?.toString()
👍 7
thank you color 1
☝️ 4
3
l
?: "null"
😄
z
If toString is called on null variable it returns "null" string
2
h
Wouldn't
variable.toString()
enough as toString returns null anyway if the variable is null?
s
@Hassaan No, if
variable
is of type
String?
you can’t call it this way because it’s unsafe.
👍 1