Prompt, how to receive in a method “getProperty” a...
# announcements
b
Prompt, how to receive in a method “getProperty” a field name?
Copy code
abstract class DemoSuper() {
  protected fun getProperty(defaultValue: String): String {
    // field name?
    return defaultValue
  }
}

class Demo : DemoSuper() {
  val f0: String by lazy { getProperty("f0") }
  val f1: String by lazy { getProperty("f1") }
}
d
You would have to write your own property delegate (like lazy). Then you would get the
KProperty
passed in
b
thx