February 2018
Intermediate to advanced
356 pages
9h 10m
English
Let's understand how we can construct functions without a return value, the following function will not return any value:
fun printGreetings(name:String,greeting:String):Unit{ println(greeting + name)}
There is one difference, in this case, the Unit was introduced; this type of object corresponds to void in Java language. Then, in the preceding code, we have a function without a return. The Unit object can be removed if you want the compiler to understand the function has no return value.