Dias
04/08/2019, 4:00 PMAny?.toString()
returns "null" rather than actual null?Ruckus
04/08/2019, 4:10 PMfun Any?.toString(): String
clearly returns String
, not String?
.Dias
04/08/2019, 4:13 PMghedeon
04/08/2019, 4:14 PMkarelpeeters
04/08/2019, 4:15 PMghedeon
04/08/2019, 4:16 PM""
, but I guess it's made like this in order to mark it as a special case, idk.karelpeeters
04/08/2019, 4:18 PMPoint(x=5, y=)
Ruckus
04/08/2019, 4:25 PMAny?.toString()
, we're talking about the definition. If we're talking about usage, it's fairly clear if I say value.toString()
vs value?.toString()
. If you understand nullability and safe execution in Kotlin, it seems perfectly clear.ghedeon
04/08/2019, 5:36 PMnull.toString()
is going to return from the first look.orangy
04/08/2019, 5:41 PMString.valueOf(null)
expression in Java 😉ghedeon
04/08/2019, 5:45 PM""
mostly in UI layer, because it makes more sense there. Anyhow, thankfully, custom extensions are easy to write.cbruegg
04/08/2019, 6:14 PMBurkhard
04/08/2019, 6:42 PMnull
as the receiver of extension functions is a different discussion (and something that will probably never change). Anyhow I like it. Functions like isNullOrEmpty
are greatRuckus
04/08/2019, 6:46 PMAs extension methods are supposed to mimic instance methods...That seems a rather unfounded claim. Can you justify it?
cbruegg
04/08/2019, 6:47 PMRuckus
04/08/2019, 6:48 PMcbruegg
04/08/2019, 6:48 PMRuckus
04/08/2019, 6:52 PMBurkhard
04/08/2019, 6:54 PM.
vs ->
.Ruckus
04/08/2019, 6:58 PM