Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Kotlin
Kotlineasy

Kotlin null-safety — what do `?`, `?.`, `?:`, and `!!` mean?

Tags
#null-safety#elvis#nullable
Back to categoryPractice quiz

Answer

`T?` is a nullable type, `?.` is a safe call, `?:` (Elvis) provides a default, and `!!` asserts non-null (throws if it’s null).

val name: String? = null
val len = name?.length ?: 0
// val crash = name!!.length // throws if name is null

Related questions

Kotlin
`lateinit` vs nullable property: when would you choose `lateinit`?
#kotlin#lateinit#null-safety
Kotlin
Kotlin smart casts: when do they work and when do they not?
#kotlin#smart-cast#type-safety
Kotlin
What is `lateinit` and when can you use it?
#lateinit#null-safety#properties
Kotlin
Explain null safety in Kotlin.
#null-safety#nullable#elvis-operator