fun main() { // a nullable type is spelled with a trailing ? val maybe: String? = null // ?. short-circuits, ?: supplies a fallback println(maybe?.length ?: -1) }
mark null with ? and default with ?: