let()

let() is a useful function defined in Kotlin standard library. It can be used for scoping and null-checks.

import java.io.File

fun main(args: Array<String>) {
//sampleStart
File("input.txt").let {
    it.exists()                     // 1
}
//sampleEnd
}
  1. file object is now accessible by reference it