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

Florian

08/10/2021, 10:41 AM
I want to turn an
Int?
into a
String?
but if the
Int?
is
null
I don't want to have a literal
"null"
String, I want the string value to be
null
. Is there an operator for this or do I have to check it manually?
a

arekolek

08/10/2021, 10:44 AM
Copy code
null?.toString() == null
f

Florian

08/10/2021, 10:45 AM
that expression doesn't turn an Int into a String
a

arekolek

08/10/2021, 10:47 AM
image.png
☝🏼 1
d

Dominaezzz

08/10/2021, 10:47 AM
Copy code
val num: Int? = ...
num?.toString()
f

Florian

08/10/2021, 10:53 AM
oh thank you
my mistake was somewhere else
I called
toString()
on that nullable String instead of
orEmpty()
👍 1
5 Views