feat:ChatGPT第 6 课:占位符 _、参数类型推断、匿名函数简写。
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package practise6.exercises
|
||||
|
||||
/*
|
||||
练习 4
|
||||
|
||||
把:
|
||||
val add: (Int, Int) => Int = (a, b) => a + b
|
||||
改成 _。
|
||||
|
||||
要求:
|
||||
println(add(10, 20))
|
||||
|
||||
输出:
|
||||
30
|
||||
*/
|
||||
object Exercises4 {
|
||||
def main(args: Array[String]): Unit = {
|
||||
val add: (Int, Int) => Int = _ + _
|
||||
println(add(10, 20))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user