特牛生活网

Scala方法形参中传入函数作为参数_scala 方法中的参数是函数-CSDN博客

网友收藏
文章浏览阅读2.3k次。在Scala中可以将函数作为参数传递到另一个方法中,代码如下:object FunctionTest { def main(args: Array[String]): Unit = { test(plus) } def test(fun: => Unit): Unit = { println("this is test run") fun } def plus() = { println("this is plus run") }_scala 方法中的参数是函数