对于这段代码,Kotlin迫使我处理无效检查情况,而在另一条线上则没有,尽管情况相同:
if (r1 == null && r2 == null)
throw IllegalArgumentException("All nulls!")
else if (r1 == null)
return r2!!.reading // <----- I am forced to !! here
else if (r2 == null)
return r1.reading // <----- The compiler does not complain in this line
Run Code Online (Sandbox Code Playgroud)
这是一个错误还是一个功能?
归档时间: |
|
查看次数: |
177 次 |
最近记录: |