feat:线下课:流程控制、方法和函数
ChatGPT:第 2 课:Scala 函数与方法
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package practise2.exercises
|
||||
/*
|
||||
练习 1:加法函数
|
||||
|
||||
定义:
|
||||
add(a, b)
|
||||
|
||||
要求:
|
||||
输入 10 和 20
|
||||
返回 30
|
||||
|
||||
调用:
|
||||
println(add(10, 20))
|
||||
*/
|
||||
|
||||
object Exercises1 {
|
||||
def main(args: Array[String]): Unit = {
|
||||
print(add(10,20))
|
||||
}
|
||||
def add(a: Int, b: Int): Int = a + b
|
||||
}
|
||||
Reference in New Issue
Block a user