Skip to content
Justice Tech School

Destructuring and Typealias

Destructuring unpacks a data class or pair into variables. typealias gives a type a shorter name.

Example
typealias Scores = Map<String, Int>
val s: Scores = mapOf("Ada" to 90)
val (name, pts) = "Tunde" to 80
println("$name $pts $s")

Exercise

Short type name.

 Ids = List<Int>

Quiz Test

What does typealias do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.