[英]Kotlin functions with multiple default arguments: How to leave values out?
Let's say I've got the following function:假设我有以下 function:
fun main(args: Array<String>) {
demo("Test", 48)
}
fun demo(a: String = "a not given", b: Int = 0) {
println("$a und $b")
}
How would I invoke demo(), providing only the second parameter (the integer)?我将如何调用 demo(),只提供第二个参数(整数)?
It will work try it它会工作试试
fun main(args: Array<String>) {
demo(b = 48)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.