By default, Kotlin variables cannot hold null. Writing var name: String = null won't even compile! To allow null, append a question mark (String?)—and Kotlin forces you to handle the null case before accessing properties like .length.
ADVERTISEMENT