Hi. Is there a way to iterate all the components o...
# getting-started
t
Hi. Is there a way to iterate all the components of a data class?
s
What exactly do you want to achieve?
t
I have a data class and I need to extract all the property names
s
You could probably use reflection and `KClass`' `members’
Or you could also use Destructuring Declarations - data classes automatically declare
componentN()
functions: https://kotlinlang.org/docs/reference/multi-declarations.html#example-returning-two-values-from-a-function
h
With destructuring you won't get field names I think.