scala匿名函数

2019-03-13  本文已影响0人  行走于无形之中

匿名函数可以说是没有名字的函数

package run

object fun {
  def main(args: Array[String]): Unit = {
    sayHello("world")

  }
  
  val sayHello = (str:String) =>{
    print(s"hello $str")
  }
  
}

scala> sayHello("world")
hello world
上一篇 下一篇

猜你喜欢

热点阅读