Kotlin - why do I get a KotlinNullPointerException

后端 未结 4 1771
借酒劲吻你
借酒劲吻你 2021-01-17 15:50

Consider the following code:

Example

fun main(args: Array) {
    maybeWriteMessage()
}

fun maybeWriteMessage(message:         


        
4条回答
  •  失恋的感觉
    2021-01-17 16:14

    Operator !! throws an KotlinNullPointerException if message is null.

    You can read about it here: https://kotlinlang.org/docs/reference/null-safety.html#the--operator

提交回复
热议问题