struggling to understand how to use reflection to ...
# announcements
b
struggling to understand how to use reflection to get values out of an
object
hierarchy e.g. i have:
Copy code
object foo {
  object bar {
    val barval = "123"
    val barval2 = "234"
  }
  object  baz {
    val bazval = "abc"
    val bazval2 = "bcd
  }
}
how can i programmatically get 123, 234, abc, bcd.
Copy code
foo::class.nestedClasses.forEach{klazz ->
    klazz.memberProperties.forEach{ it: KProperty1<out Any,*>
        println(it)
    }
}
gets me all the properties e.g.
Copy code
val foo.bar.barval: kotlin.String
val foo.bar.barval2: kotlin.String
val foo.baz.bazval2: kotlin.String
val foo.baz.bazval2: kotlin.String
but i’m unclear on how to actually get those values