DEV Community

WanTobeme
WanTobeme

Posted on

What is Unit in Kotlin?

Unit is an object. The type with only one value return: the Unit object. This type corresponds to the void type in Java.

Example:
onClick: () -> Unit
onClick is a Function Unit return, just like void in java.

Source:
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/

Top comments (0)