You can use values
like so:
val genders = Gender.values()
Since Kotlin 1.1 there are also helper methods available:
val genders = enumValues<Gender>()
With the above you can easily iterate over all values:
enumValues<Gender>().forEach { println(it.name) }
To map enum name to enum value use valueOf
/enumValueOf
like so:
val male = Gender.valueOf("Male")
val female = enumValueOf<Gender>("Female")
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…