我目前正在 Android Studio 3.1 中开发 Kotlin
从 JsonReader 中我收到一个 String!
,我正在尝试将其转换为大写
所以我要做的是:
var name=reader.nextString().toUpperCase()
问题是,未检测到 toUpperCase
并将其标记为未解析的引用
最佳答案
toUpperCase()
方法被定义为 String
的内联扩展函数,而不是 java.lang.String
。因此,您需要将 Kotlin 标准库作为依赖项才能将此方法用于 String
。
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
关于android - 未解析的引用 :toUpperCase Kotlin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49646743/