Kotlin - Data Types
Which of the following is the correct way to declare a function that returns
Unit explicitly in Kotlin?Unit explicitly in Kotlin?: before the return type, so fun greet(): Unit is correct.-> which is invalid syntax. fun greet(): void { println("Hello") } uses void which is not a Kotlin type. fun greet() { return Unit } tries to return Unit explicitly but misses the return type declaration.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions