标签:func font span extend int else print function family
object test extends App{
val fun1=(x:Int,y:Int)=>x+y
val fun2=((x:Int,y:Int)=>x+y)
val fun3=(_:Int)+(_:Int)
val fun4:(Int,Int)=>Int=(_+_)
val fun5:(Int,Int)=>Int=(x,y)=>x+y
val fun6=new Function2[Int,Int,Int]{
override def apply(x: Int, y: Int): Int = if(x<y) x else y
}
val fun7=(x:Int,y:Int)=>if(x<y) x else y
//无参函数,小括号不能省
val fun8=()=>println("haha")
fun8()
}
标签:func font span extend int else print function family
原文地址:https://www.cnblogs.com/hotMemo/p/9975108.html