Jarek Rozanski
12/15/2019, 2:31 PM.let and nullability.
Code snippet:
val foo : String? = "sample"
foo.let { it.toUpperCase() }
Results in:
Only safe (?.) or non-null asserted (!!.) calls are allowed on a nullable receiver of type String?karelpeeters
12/15/2019, 2:33 PMpublic inline fun <T, R> T.let(block: (T) -> R): R
So no, there's no restriction on the nullability of T.karelpeeters
12/15/2019, 2:33 PMfoo?.let { it.toUpperCase() }Jarek Rozanski
12/15/2019, 2:34 PM? ...karelpeeters
12/15/2019, 2:35 PMlet specifically, it works just as well for other functions.Jarek Rozanski
12/15/2019, 2:35 PM? and was expecting some magic. Was about to blame Kotlin version upgrade. simple smileMike
12/15/2019, 3:24 PMfoo?.toUpperCase(). IntelliJ or Detekt should warn about unnecessary let