import java.util.Datejava
object ApplicationFun {
def main(args:Array[String])
{
val date = new Date()
log(date,"message1")
log(date,"message2")
log(date,"message3")
val appfun = log(date,_:String) //仔細觀察
appfun("appmessage1")
Thread.sleep(2000)
appfun("appmessage2")
Thread.sleep(2000)
appfun("appmessage3")
}
def log(date:Date,message:String)={
println(date+"====="+message)
}
}app
實驗結果以下:函數
Mon Apr 30 20:21:19 CST 2018=====message1
Mon Apr 30 20:21:19 CST 2018=====message2
Mon Apr 30 20:21:19 CST 2018=====message3
Mon Apr 30 20:21:19 CST 2018=====appmessage1
Mon Apr 30 20:21:19 CST 2018=====appmessage2
Mon Apr 30 20:21:19 CST 2018=====appmessage3ui
2018.5.14 Scala之偏函數Partial Function.net
https://blog.csdn.net/bluishglc/article/details/50995939blog