feat:ChatGPT第 3 课:函数对象、匿名函数、=>、map

This commit is contained in:
2026-09-13 16:11:11 +08:00
parent d08ecade11
commit d589eeaf30
15 changed files with 292 additions and 0 deletions
@@ -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))
}
}