比方说,我们有以下的扩展功能:从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