【发布时间】:2019-12-17 09:12:44
【问题描述】:
我想从这个类之外调用类SomeClass的私有函数:
class SomeClass {
private fun somePrivateFunction() {
//...
}
private fun somePrivateFunctionWithParams(text: String) {
//...
}
}
在代码中的某处我引用了SomeClass 对象:
val someClass = SomeClass()
// how can I call the private function `somePrivateFunction()` from here?
// how can I call the private function `somePrivateFunctionWithParams("some text")` from? here
如何在 Kotlin 中从类外调用带参数和不带参数的私有函数?
【问题讨论】:
标签: kotlin reflection private private-methods private-functions