https://kotlinlang.org logo
d

DALDEI

08/09/2019, 2:15 AM
Given an object instance and class is there a way to bind the class member properties to the instance to produce a bound property reference ? E.g. convert a KProperty1 to a KProperty0 Say ``` fun bind( obj: Any ) : List<KProperty0<*>> { val props1= obj::class.memberProperties // KProperty1<T,R> return props.map { bind( it , obj ) ???? } // KProperty0<R> } I can do this: fun bin( knownObject: MyClass ) = listOf( knownObject::prop1 , knownObject::prop2 , ...) But cant find a way to do so generically (without enumerating each property by name/accessor )
I found this from apr 2018 ---> is this still true :? https://kotlinlang.slack.com/archives/C0AVAB92L/p1524476593000480
u

udalov

08/12/2019, 3:31 PM
Unfortunately, there's no official way to bind a property receiver, but you can try the workaround suggested in the mentioned thread
3 Views