我有一个可以为空的字符串变量ab.如果我toUpperCase在为其分配null后通过安全调用操作符调用,则kotlin会给出错误.
fun main(args: Array<String>){
var ab:String? = "hello"
ab = null
println(ab?.toUpperCase())
}
Run Code Online (Sandbox Code Playgroud)
错误:( 6,16 )
重载分辨率歧义:
@InlineOnly public inline fun Char.toUpperCase():在kotlin.text中定义的char
@InlineOnly public inline fun String.toUpperCase():在kotlin.text中定义的字符串
这有什么问题?
我将一个ndk项目从windows移动到linux(ubuntu).然后突然我得到了上面的错误.但是这个项目在windows中无缝构建.即使我在ndk-clean时遇到此错误.
我有一个方法:
fun sum(first:Int, second:Int):Int
{
return first + second
}
Run Code Online (Sandbox Code Playgroud)
我可以像使用变量一样在字符串模板内使用参数调用此方法吗?
我尝试了以下方法,但没有成功:
println("$sum(3,4)")
Run Code Online (Sandbox Code Playgroud)