Kotlin中方法调用参数可能为null得正确写法

2019-03-28  本文已影响0人  tommyRen

编译错误信息如下:

Smart cast to 'Node' is impossible, because 'left' is a mutable property that could have been changed by this time

Smart cast to 'xxxx' is impossible, because 'xxxx' is a property that has open or custom getter

例如下边这行代码 

解决方法:1:是使用本地变量。 2:使用safe call 安全调用。 3: Elvis操作符 

上一篇 下一篇

猜你喜欢

热点阅读