What is the Kotlin double-bang (!!) operator?

后端 未结 3 1351
天涯浪人
天涯浪人 2020-12-02 08:28

I\'m converting Java to Kotlin with Android Studio. I get double bang after the instance variable. What is the double bang and more importantly where is this documented?

3条回答
  •  情话喂你
    2020-12-02 08:39

    This is unsafe nullable type (T?) conversion to a non-nullable type (T), !! will throw NullPointerException if the value is null.

    It is documented here along with Kotlin means of null-safety.

提交回复
热议问题