MST

星途 面试题库

面试题:Kotlin高阶函数之函数类型理解

在Kotlin中,定义一个接受两个Int类型参数,并返回一个Int类型结果的高阶函数 `higherOrderFunction`,该高阶函数接受另一个函数类型参数 `operation`,`operation` 同样接受两个Int类型参数并返回Int类型结果。请实现这个 `higherOrderFunction`,并在其中调用 `operation` 函数对传入的两个Int参数进行操作并返回结果。
20.6万 热度难度
编程语言Kotlin

知识考点

AI 面试

面试题答案

一键面试
fun higherOrderFunction(a: Int, b: Int, operation: (Int, Int) -> Int): Int {
    return operation(a, b)
}