Last active 1725104485

rcaldous's Avatar rcaldous revised this gist 1725104485. Go to revision

1 file changed, 0 insertions, 0 deletions

EnumString.Kt renamed to EnumString.kt

File renamed without changes

rcaldous's Avatar rcaldous revised this gist 1725104476. Go to revision

1 file changed, 8 insertions

EnumString.Kt(file created)

@@ -0,0 +1,8 @@
1 + // https://stackoverflow.com/questions/28548015/how-do-i-create-an-enum-from-a-string-in-kotlin
2 + inline 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 + }
Newer Older