可循环观察的代表

在某些情况下是否有可能规避可观察的代表?

用例:

val ls: ArrayList by Delegates.observable(arrayListOf()) { _, _, new -> if (someCondition) { usesList(new) // I want to reset ls to arrayListOf(), but without the invocation of the observable delegate. } } 

当然…你必须在你的classpath中有kotlin-reflection。 我不会推荐使用这个。 🙂

 val delegatedProperties = D::class.java.getDeclaredField("\$\$delegatedProperties").get(d) as Array> (delegatedProperties.find { it.name == "ls" } as KMutableProperty<*>).setter.call(arrayListOf())