Kotlin use string to call method

Viewed 41

i have the following situation:

  1. i have a sealed class containing data class

  2. the call look like : SealedClass.V1 (for the version 1 of the data) V2 and etc...

  3. i got the data version from the device

  4. i would like to call my data class like this :

val version = "V$dataVersion" //so should be V1
SealedClass.version(someStuff)

is there a way to do that(currently my way to do this is with when(version) but it could came messy if at some point we got more version of the data structure

0 Answers
Related