Kotlin中问号(?)和两个叹号(!!)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/android_gjw/article/details/78436707

先看一段代码

  private var cloth_Rv: RecyclerView ?= null

  cloth_Rv!!.setHasFixedSize(true)

?:表示当前是否对象可以为空

!!: 表示当前对象不为空的情况下执行

都是Kotlin为我们提供的检验空指针的方法

《Kotlin语法基础到实战开发》系列课程视频

http://edu.csdn.net/course/detail/6409?locationNum=7&fps=1&ref=srch&loc=1

http://edu.csdn.net/course/play/6409/123752

猜你喜欢

转载自blog.csdn.net/android_gjw/article/details/78436707