I need help with enums. Is possible to go to next ...
# getting-started
z
I need help with enums. Is possible to go to next enum value easier than solution in this example? http://try.kotlinlang.org/#/UserProjects/vfgallbbhplq0mau2aatvj7u4h/m3qu18a7lgpdl7tjr76vpr1a4i
m
z
thanks 👍
m
@miha-x64 Nice one. Was going to suggest to define a generic extension function on Enum to get the next element, but then remembered that the Enum class itself doesn't have the values() method, and that it's instead generated by the compiler for each concrete subclass on the fly.
m
@matej it’s still possible to get
$VALUES
array using reflections, if you’re going to use inline fun with reified type. 🙃
b
What’s the use case for getting the next enum. Is this sufficient?
Copy code
for(phase in PHASE.values())
    {
        //Do something with phase
    }