加载中...

字符串内嵌表达式和参数默认值

字符串内嵌表达式

"hello, ${obj.name}. nice to meet you!"
另外,当表达式中仅有一个变量的时候,还可以将两边的大括号省略,如下所示:
"hello, $name. nice to meet you!"

函数的参数默认值

fun printParams(num: Int, str: String = "hello") {
 println("num is $num , str is $str")
}
posted @ 2022-09-06 16:30  biubidio  阅读(17)  评论(0)    收藏  举报