Kotlin - Data Types
What is the output of this Kotlin code?
fun doNothing(): Unit = Unit
fun main() {
val x = doNothing()
println(x == Unit)
}fun doNothing(): Unit = Unit
fun main() {
val x = doNothing()
println(x == Unit)
}doNothing returns the singleton Unit object explicitly. Since x is Unit, x == Unit is true.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions