I have ran the following code on play.kotlinlang.org but the result keeps saying: Type mismatch: inferred type is Unit but String is expected
(I made some changes from the original example code)
I have no idea why its inferring type is Unit.
I thought I announced the returning type as String.
Is the type of println() Unit or have I just wrote the whole ring function wrong?
fun main(){
val squid:(String)->String={str->println("I'm $str")}
//ring(::rabbit)
ring(squid)
}
fun rabbit(str:String):String{
println("I'm $str")
return str
}
fun ring(carrot:(String)->String){
carrot("a appetiting squid")
}