Hi, how can I get a list of `KMutableProperty1<...
# reflect
a
Hi, how can I get a list of
KMutableProperty1<*, *>
for the members of my class ? I only found
memberProperties
which returns a list of
KProperty<*, *>
and not castable so what should I use ?
r
a simple
is KMutableProperty1<*, *>
check on the list should do it add a
filterIsInstance
which does the is check on whole collection and buala:
Copy code
data class Example(
    val one: Int,
    var two: String,
    val three: String,
    var four: Int,
)

val mutableProperties: List<KMutableProperty1<*, *>> =
    Example::class.memberProperties.filterIsInstance<KMutableProperty1<*, *>>()

mutableProperties.map { it.name to it.returnType }  
// == [(four, <http://kotlin.Int|kotlin.Int>), (two, kotlin.String)]
(the type of the variable is not needed, only there to be clear what it is)
a
oh okay I see, thanks !