<Is there a way to call the `values()` function on...
# forum
r
Is there a way to call the `values()` function on generic Enum type without too much code repetition? I’m trying to implement a Command class. The idea is that a Command can have no additional arguments or some additional arguments, and I’d like the additional arguments to be Enums in order to be compile-time defined. Here is what I came up with: interface Arguments { fun commandList() : List } enum class Args1 : Arguments { On, Off; override fun commandList() = Args1.values().asList() } enum class Args2 : Arguments { On, Off; override fun commandList() =...