diesieben07
12/18/2017, 6:16 PMas Any? only works because there is such an overload for println.
Following example does not work:
fun main(args: Array<String>) {
var test = Test(null)
if (test.foo != null) {
myFun(test.foo as Int?) // "Unnecessary cast"
myFun(test.foo) // Tries to smart-cast and fails, compile error
}
}
fun myFun(a: Int) = Unit
fun myFun(a: Int?) = Unit