This is throwing the error: Exception in thread "main" java.lang.IllegalArgumentException: No enum constant Color.red
enum class Color(val value: String = "") {
RED("red"),
YELLOW("yellow"),
BLUE("blue")
}
fun main() {
print(Color.valueOf("red"))
}
The above will only work if I change the print statement to:
print(Color.valueOf("RED"))
Is it possible to use a custom string to assign to an enum value using the valueOf?