当我写这个kotlin代码时,我不知道为什么会遇到这样的问题
Log.d(TAG, msg:"onCreate called. Score is :$score")
Run Code Online (Sandbox Code Playgroud)
我假设你试图使用命名参数,判断我msg是第二个参数的名称Log.d,并在代码中匹配.但是,你有两个问题:
=,而不是:就像你可以做的那样:
data class SomeClass(val x: String, val y: String)
fun someFunction(){
SomeClass(y = "y", x = "x")
}
Run Code Online (Sandbox Code Playgroud)
但你不能这样做Log.d,因为它不是Kotlin功能.作为参考,这是适当的语法:
Log.d(TAG, msg="onCreate called. Score is :$score")
Run Code Online (Sandbox Code Playgroud)
但它不会编译,因为Named arguments are not allowed for non-Kotlin functions.所以删除它.您不能在该方法中使用命名参数.
| 归档时间: |
|
| 查看次数: |
1331 次 |
| 最近记录: |