KotlinSyntax
Safe Call and Elvis
Code example
val len = name?.length ?: 0Handles null safely with a default.
In Kotlin, safe call and elvis: handles null safely with a default — val len = name?.length ?: 0
val len = name?.length ?: 0val len = name?.length ?: 0Handles null safely with a default.
Use val len = name?.length ?: 0.
Use this pattern: val len = name?.length ?: 0
Yes. Use Copy code and adapt the example to your program.
No. The language syntax is the same across operating systems.