kotlin把函数作为参数转递给另一个函数
fun say(s: String, foo: (String) -> Unit) {
print("hello")
foo(s)
}
fun hi(str: String) {
println(str)
}
fun main(args: Array<String>) {
say("hello", ::hi)
}
输出:
hellohello
kotlin把函数作为参数转递给另一个函数
fun say(s: String, foo: (String) -> Unit) {
print("hello")
foo(s)
}
fun hi(str: String) {
println(str)
}
fun main(args: Array<String>) {
say("hello", ::hi)
}
输出:
hellohello