fun main() {
//匿名函数
val niminginfo=niming("kotlin",20,{
"$it"
})
println(niminginfo)
//具名函数 理解:showResult:(String)->String):String==showResultImpl(result:String):String
val juminginfo=niming("c++ ",20,::showResultImpl)
println(juminginfo)
}
//具名函数
fun showResultImpl(result:String):String{
return result
}
inline fun niming(name:String,age:Int,showResult:(String)->String):String{
val msg="我叫$name,我今年$age"
return showResult(msg)
}
执行结果