Chris
06/09/2021, 4:50 PMit.toString()
or
2️⃣ "$it"
or
3️⃣ something else?
Is 1️⃣ and 2️⃣ equivalent?Michael Böiers
06/10/2021, 11:38 AM2
? If it’s really equivalent (no performance penalty), it’s actually more concise.it?.toString() ?: "null"
?
EDIT: I was wrong, they are equivalent. 🙂mkrussel
06/10/2021, 1:04 PMtoString
in Kotlin is an extension on Any?
and handles null correctly.Chris
06/10/2021, 1:06 PMIllegalFormatConversionException
.
I’m still none the wiser as to why because they both produce a String.Michael Böiers
06/10/2021, 4:33 PM"null"
, would have expected null
. I learn something new about Kotlin every day! 🙂Chris
06/11/2021, 7:24 AM