在刚开始用Kotlin写代码的时候经常因为!!和?不加报警告错误。
具体提示如下代码所示:
protected var loadingDialog: Dialog? = null
//java隐藏actionBar
if (null != getActionBar()) {
getActionBar().hide();
}
//Kotlin隐藏actionBar
actionBar?.hide()
//Kotlin调用弹出框显示方法
loadingDialog?.show()
假如你不加!!或者?,会出现如下告警提示
Smart cast to 'loadingDialog' is impossible, because 'loadingDialog' is a mutable property that could have been changed by this time
网友评论