Tasos Stamadianos
12/19/2018, 8:49 PMtry-catch-null-check.kt:22:24: error: operator call corresponds to a dot-qualified call 'nullableVal.plus(1)' which is not allowed on a nullable receiver 'nullableVal'.
val sum = nullableVal + 1
^Tasos Stamadianos
12/19/2018, 8:54 PMdummy!! on line 15, I get this warning: try-catch-null-check.kt:15:8: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int
dummy!!
^
I can also explicitly specify the type of the try/catch and it works fine: val nullableVal: Int = try {Ruckus
12/19/2018, 8:57 PMtryTasos Stamadianos
12/19/2018, 8:57 PMTasos Stamadianos
12/19/2018, 8:58 PMTasos Stamadianos
12/19/2018, 8:58 PM!! on dummy, then it's certainly smart enough to know I'm doing the null checkRuckus
12/19/2018, 8:58 PMdummy is null, you are returning it outside the check where it is still Int?, so that's the inferred typeTasos Stamadianos
12/19/2018, 8:59 PMTasos Stamadianos
12/19/2018, 8:59 PMRuckus
12/19/2018, 8:59 PMTasos Stamadianos
12/19/2018, 9:00 PMRuckus
12/19/2018, 9:00 PMTasos Stamadianos
12/19/2018, 9:00 PMdsavvinov
12/20/2018, 9:04 AMnullableVal explicitly as Int (as actually, you make sure that its nonnullableVal 🙂 )