Android ● ○ ○ Kotlin 2.0

Kodebits Day 33: Data Class Destructuring

Jun 2 2026
Practice data classes with a short kotlin challenge.

What does this print?

data class Point(
  val x: Int, val y: Int
)

fun main() {
  val p = Point(3, 7)
  val (a, b) = p
  println(a + b)
}


Try it in the online Kotlin Playground →

[spoiler title="Solution"]

Answer:

10

Explanation:

Data classes auto-generate destructuring for properties.

[/spoiler]


Further Reading