kotlin check if null code example
Example 1: !! in kotlin
//The not-null assertion operator
val l = b!!.length
Example 2: elvis operator kotlin example
val l = b?.length ?: -1
Example 3: null check in kotlin
if(a != null) {
//do something
}
//The not-null assertion operator
val l = b!!.length
val l = b?.length ?: -1
if(a != null) {
//do something
}