比方說,我們有以下的擴展功能:從Kotlin的另一個類訪問靜態擴展函數?
class Helper {
companion object {
fun Int.plus(value: String) = Integer.valueOf(value).plus(this)
}
}
你怎麼能在Helper
類訪問plus
擴展功能在另一個類。有沒有一種方法,我們可以例如做這樣的事情:
class OtherClass {
fun someMethod() {
val eight = 7.Helper.Companion.plus("1")
}
}
感謝您花時間回答這個問題 – user2491598