```inline fun <reified T : Enum<T>> Li...
# announcements
c
Copy code
inline fun <reified T : Enum<T>> List<String>.toEnums(): List<T> {
  return this.map {
    enumValueOf<T>(it)
  }
}
a
Here is my solution (possibly not the most optimal):
inline fun <reified T:Enum<T>> List<String>.toEnums(): List<T> = T::class.java.enumConstants.filter { it.name in this }.toList()
Here is a full example: ` fun main(args: Array<String>) { val widgets = listOf("TOGGLE","BUTTON").toEnums<WidgetType>().toSet() val expected = setOf(WidgetType.TOGGLE, WidgetType.BUTTON) assertTrue { expected == widgets } } '
c
Just seeing this now. It’s a bit late, but thanks!