Kotlin语言基础(下)
8、函数
/**
* 函数的标准写法如下,Unit表示无返回类型,相当于Java里的void
*/
fun add(x: Int, y: Int): Int {
return x + y
}
/**
* 命名参数、默认参数、可变参数
*/
fun method1(name: String, age: Int, value: Int) {
}
fun method2(name: String, age: Int = 20, value: Int) {
}
fun method3(name:
原创
2020-08-04 09:43:25 ·
143 阅读 ·
0 评论