https://kotlinlang.org logo
Title
t

tekjar

11/20/2017, 11:31 AM
Hi. Is there a way to iterate all the components of a data class?
s

satejs

11/20/2017, 11:39 AM
What exactly do you want to achieve?
t

tekjar

11/20/2017, 11:44 AM
I have a data class and I need to extract all the property names
s

stan0

11/20/2017, 2:17 PM
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

holgerbrandl

11/20/2017, 5:13 PM
With destructuring you won't get field names I think.