!! in kotlin
//The not-null assertion operator
val l = b!!.length
!! in kotlin
//The not-null assertion operator
val l = b!!.length
kotlin Null Safety
// Variable types in Kotlin don't allow the assignment of null.
// Declare a nullable varible by adding ? at the end of its type.
var neverNull: String = "This can't be null"
neverNull = null // Error
var nullable: String? = "You can keep a null here"
nullable = null // Ok
var inferredNonNull = "The compiler assumes non-null"
inferredNonNull = null // Error
fun strLength(notNull: String): Int {
return notNull.length
}
strLength(neverNull) // Ok
strLength(nullable) // Error
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us