apatrida
12/31/2015, 12:07 PMval
vs. var
… it is more complicated than that. var
can work if local and is captured by expression. See all cases here http://stackoverflow.com/a/34498563/3679676 under "More about null Checking and Smart Casts”
From beta 1 announcement there was a recent change (http://blog.jetbrains.com/kotlin/2015/10/kotlin-1-0-beta-candidate-is-out/)
Smart casts now work even on local var‘s that are captured in lambdas, if they are not mutated in those lambdas: