4 ms·
The first case would be a compile time error in Kotlin. How is a runtime AssertionError better than a runtime NullPointerException?
by quarterto 12y ago
The first case would be a compile time error in Kotlin. How is a runtime AssertionError better than a runtime NullPointerException?
- newgame 12y ago> The first case would be a compile time error in Kotlin FYI, Kotlin will have the same behavior as Ceylon in the future, i.e. it's going to be a runtime error in the first case: http://blog.jetbrains.com/kotlin/2014/10/making-platform-interop-even-smoother/ http://blog.jetbrains.com/kotlin/2014/10/making-platform-int...
- gavinking 12y agoWell it is somewhat better because it occurs immediately when the null value passes from Java code with unsafe null into Ceylon code with safe nulls. Having the compiler produce an actual error in this case seems wrong and excessive, since the compiler does _not_ know better than you whether javaMethod() can return null. It simply doesn't have that information when calling Java code.