https://kotlinlang.org logo
#announcements
Title
# announcements
k

kirillrakhman

06/09/2017, 2:04 PM
Copy code
fun main(args: Array<String>) {
    println(valueOf("Enum1"))
}

fun valueOf(name: String) = MyEnum::class.java.declaredClasses
	.first { it.simpleName == name }
	.kotlin
	.objectInstance as MyEnum

sealed class MyEnum {
    object Enum1: MyEnum()
    object Enum2: MyEnum()
}