How can I create "static" method for enum in Kotiln?
Just like with any other class, you can define a class object in an enum class:
enum class CircleType {
FIRST,
SECOND,
THIRD;
companion object {
fun random(): CircleType = FIRST // http://dilbert.com/strip/2001-10-25
}
}
Then you'll be able to call this function as CircleType.random()
.
EDIT: Note the commas between the enum constant entries, and the closing semicolon before the companion object. Both are now mandatory.