Last active
June 14, 2019 09:27
-
-
Save BurakDizlek/c43e95478ca5c309c34970b24dfff6de to your computer and use it in GitHub Desktop.
no enum constant for default safe enum value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <reified T : kotlin.Enum<T>> safeEnumValueOf(type: String?,defaultEnum:T): T { | |
return try { | |
java.lang.Enum.valueOf(T::class.java, type) | |
} catch (e: Exception) { | |
defaultEnum | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi , Yeah you are right. It can be T instead of T? .