Android ● ● ○ Kotlin 2.0

Kodebits Day 85: Type Check As Cast

Aug 31 2026
Practice type checks with a short kotlin challenge.

What does this print?

fun main() {
  val x: Any = 42
  val n = x as Int
  println(n * 2)
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

84

Explanation:

as explicitly casts a value to the specified type.

[/spoiler]


Further Reading