📜  kotlin 中的 let 关键字 - 任何代码示例

📅  最后修改于: 2022-03-11 14:54:59.456000             🧑  作者: Mango

代码示例2
let can be used to check null expressions. 

fun main(args: Array) {
    var name : String? = "Kotlin let null check"
    name?.let { println(it) } //prints Kotlin let null check
    name = null
    name?.let { println(it) } //nothing happens
}

//The code inside is executed only when the property is not null.