how can I get the value of a field, when I only kn...
# announcements
x
how can I get the value of a field, when I only know the name of the field (as a string)? I don’t see an example in https://kotlinlang.org/docs/reference/reflection.html
Copy code
@ParameterizedTest
    @ValueSource(strings = [ "emr", "packet_100hz", "packet_1hz" ])
    fun channel( channel: String ) {
        assertThat( Channel::class.java ).hasPublicFields( channel.toUpperCase() + "_NEW" )
        assertThat( Channel::`channel`.get() ).isEqualTo( channel + ".new" )
    }
d
kClass.members.find { it.name == knownName }
👍 1