Last active 1725104485

EnumString.kt Raw
1// https://stackoverflow.com/questions/28548015/how-do-i-create-an-enum-from-a-string-in-kotlin
2inline fun <reified T : Enum<T>> valueOf(type: String): T? {
3 return try {
4 java.lang.Enum.valueOf(T::class.java, type)
5 } catch (e: Exception) {
6 null
7 }
8}