alakazam.kotlin.core.EnumFromString.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-core Show documentation
Show all versions of kotlin-core Show documentation
A set of useful functions and extensions for Kotlin development.
package alakazam.kotlin.core
public inline fun > enumFromString(string: String): E =
enumFromStringOrNull(string) ?: error("No value matching $string")
public inline fun > enumFromStringOrNull(string: String): E? =
enumValues().firstOrNull { it.toString() == string }