groostav
12/21/2018, 7:54 PMfun `kotlin is pretty smart`(){
val nullableSet: Set<Int>? = setOf(1, 2, 3)
when(nullableSet?.size){
null -> {}
else -> { nullableSet.first() }
}
}
I would've thought that I'd need a nullableSet!! in the second case.
does that mean the smart-cast system was able to infer that
well the expressionif so, that kotlinc is one sharp cookiewasn't null, andnullableSet?.sizecan never be null, sosizemust also not be null, so I can smart-cast it tonullableSetSet<Int>
Dominaezzz
12/21/2018, 8:31 PMserebit
12/21/2018, 9:10 PMnull case in the when expression. Kotlinc is very good at smart-casting