🐦 Kotlin
Beginner
What is the Unit type in Kotlin?
Answer
Unit is Kotlin's equivalent of Java's void, but with an important difference — Unit is an actual type with exactly one value (also called Unit). A function that does not return a meaningful value has its return type set to Unit, though you can omit it from the signature. Because Unit is a real type, it can be used as a generic type argument — for example, you can have a Future<Unit> in coroutines. This makes the type system consistent, unlike Java where void cannot be used as a generic type.