I am getting RuntimeException
Enum types may not be instantiated
I don\'t know why. What I want is to identify a year by an intege
Here is another way
enum class WWGameState private constructor(var intValue: Int) {
pregame(0),
inProgress(1),
paused(2),
over(3);
companion object
{
internal fun build(i: Int): WWGameState
{
for (gs in WWGameState.values())
{
if (gs.intValue == i)
{
return gs
}
}
return WWGameState.pregame
}
}
}
Usage:
gameState = WWGameState.build(savedState!!.getInt("MODE"))