Complete the code to declare a function that returns Unit.
fun greet(): [1] { println("Hello!") }
In Kotlin, Unit is used to indicate a function returns no meaningful value, similar to void in other languages.
Complete the code to define a function with an explicit Unit return type.
fun printMessage(message: String): [1] {
println(message)
}The function explicitly returns Unit, meaning it does not return any meaningful value.
Fix the error in the function declaration to correctly use the Unit type.
fun showInfo(): [1] { println("Info displayed") }
Kotlin does not have a 'void' type. Use Unit to indicate no meaningful return value.
Fill both blanks to create a function that returns Unit and prints a message.
fun display(): [1] { println([2]) }
The function returns Unit and prints the message "Hello, Kotlin!".
Fill all three blanks to define a function that returns Unit, takes a String parameter, and prints it.
fun showMessage(msg: String): [1] { println([2]) return [3] }
The function returns Unit, prints the parameter msg, and returns Unit explicitly.