Values & References11 / 15
Up next

let on a nullable

fun main() {
    val maybe: String? = "data"
    // the block runs only if maybe is not null
    maybe?.let {
        println("got $it of length ${it.length}")
    }
}
What you're solving

run a block only when non-null