DALDEI

    DALDEI

    3 years ago
    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:😛rop1 , knownObject:😛rop2 , ...) 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
    udalov

    udalov

    3 years ago
    Unfortunately, there's no official way to bind a property receiver, but you can try the workaround suggested in the mentioned thread