Kotlin - Null Safety
Find the error in this Kotlin snippet:
fun getLength(str: String?): Int {
return str.length
}fun getLength(str: String?): Int {
return str.length
}str is nullable String, so direct access to length is unsafe.str.length without ?. or !! causes compile error.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions