What does Void return type mean in Kotlin

Viewed 38854

I tried to create function without returning value in Kotlin. And I wrote a function like in Java but with Kotlin syntax

fun hello(name: String): Void {
    println("Hello $name");
}

And I've got an error

Error:A 'return' expression required in a function with a block body ('{...}')

After couple of changes I've got working function with nullable Void as return type. But it is not exactly what I need

fun hello(name: String): Void? {
    println("Hello $name");
    return null
}

According to Kotlin documentation Unit type corresponds to the void type in Java. So the correct function without returning value in Kotlin is

fun hello(name: String): Unit {
    println("Hello $name");
}

Or

fun hello(name: String) {
    println("Hello $name");
}

The question is: What does Void mean in Kotlin, how to use it and what is the advantage of such usage?

2 Answers
Related