https://kotlinlang.org logo
#getting-started
Title
# getting-started
x

xetra11

12/29/2020, 3:36 PM
Given this enum class:
Copy code
enum class Trait(code: String) {
        AMBITIOUS("ambitious"),
        HUNTER_1("hunter_1"),
        WRATHFUL("wrathful"),
        CALLOUS("callous"),
        VIKING("viking"),
        EDUCATION_MARTIAL_3("education_martial_3")
    }
I want to access the
code
property as described in this tutorial: https://www.baeldung.com/kotlin-enum Having this statement
Copy code
val code = Trait.EDUCATION_MARTIAL_3.code
                                    ^^^^^
Where
code
Unresolved reference: code
Was the feature removed from the latest Kotlin version or what happened?
r

Robert Jaros

12/29/2020, 3:41 PM
val
is missing:
Copy code
enum class Trait(val code: String) {
...
}
🙌 1
x

xetra11

12/29/2020, 3:43 PM
...I ... I knew that
😛