Is there a way to nest an enum within a data class in Kotlin?

Viewed 12734

Is there a way to nest an enum within a data class in Kotlin?

data class D(val a:Any) {
    enum class E {F,G}
    ...
}

Or to declare it inline within a function?

fun foo() {
    enum class E {F,G}
    doSomething()
}

I can't find documentation on the rules for where enums are allowed to be declared.

2 Answers
Related