表达式 代码块 当做参数来传递 : =>Unit by name 传递参数 ,参数是一个返回值为Unit的代码块 def runIt(block: => Unit){ println("before run") block println("after run") } runIt { println("code1 run") println("code2 run") } val f = { ()=> println(1) println(2) } runIt(f()) runIt({ println(1) println(2) })