函数式变成介绍
函数具体代码介绍
object Test02
{
def
main(args
: Array
[String
]): Unit
= {
val dog
= new Dog
println(dog
.sum(10,20))
val f1
= dog
.sum _
println("f1=" + f1(15,20))
val f2
= (n1
: Int
, n2
: Int
) => {
n1
+ n2
}
println("f2=" + f2(10,50))
}
}
class Dog {
def
sum(n1
:Int
, n2
:Int
) :Int
= {
n1
+ n2
}
}
函数的定义
函数递归调用
函数注意事项
小练习题
多行函数
转载请注明原文地址: https://mac.8miu.com/read-66406.html