feat:ChatGPT第 3 课:函数对象、匿名函数、=>、map
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
package practise3.demo
|
||||
/*
|
||||
def 方法 vs => 函数值
|
||||
*/
|
||||
object Demo1DefAndFunction {
|
||||
def main(args: Array[String]): Unit = {
|
||||
def DefAdd(a: Int, b: Int): Int = a + b //这是一个方法
|
||||
val ValAdd = (a: Int, b: Int) => a + b //这是一个函数值
|
||||
println(DefAdd(10, 20))
|
||||
println(ValAdd(10, 20))
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user