Kotlin 常用语法

126 阅读1分钟

非空判断

fun test() {

    if (param == null) {
        return
    }
}

可以简写成

fun test() {
    param ?: return
}