高阶函数
Demo
object HighOrderFuncDemo01 {
def main(args: Array[String]): Unit = {
val res = test(sum, 2.0)
println(res)
val f1 = myPrint _
f1()
}
def myPrint(): Unit = {
println("Hello World!")
}
def test(f: Double => Double, n1: Double) = {
f(n1)
}
def sum(double: Double) = {
println("sum 被调用")
double + double
}
}Last updated