Android ● ○ ○ Kotlin 2.0

Kodebits Day 80: Safe Call Operator

Aug 23 2026
Practice null-safety with a short kotlin challenge.

What does this print?

fun main() {
  val s: String? = "code"
  val len = s?.length
  println(len)
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

4

Explanation:

Safe call returns the property value if not null, else null.

[/spoiler]


Further Reading