🐦 Kotlin
Intermediate
What is a type alias in Kotlin?
Answer
A type alias provides an alternative name for an existing type without creating a new type. Declared with typealias: typealias UserMap = Map<String, User>. The alias and the original type are fully interchangeable at compile time — the compiler replaces the alias with the actual type. Type aliases are most useful for shortening complex generic types, naming function types for clarity (typealias Callback = (Result<Data>) -> Unit), and giving meaningful names to platform types. Unlike value classes (inline classes), type aliases have zero runtime overhead but also provide no type safety between the alias and the original.
Previous
What is the Delegates.observable in Kotlin?
Next
What is the @JvmOverloads annotation in Kotlin?