Alexandru Gheorghe
06/12/2024, 8:16 AMCLOVIS
06/12/2024, 8:20 AMyourList.map { str -> YourEnum.entries.find { it.name == str } }
ephemient
06/12/2024, 8:25 AMephemient
06/12/2024, 8:27 AMAlexandru Gheorghe
06/12/2024, 8:27 AMnull
and handle gracefullyephemient
06/12/2024, 8:29 AMval enumNameToValue = YourEnum.entries.associateBy { it.name }
yourList.map { enumNameToValue[it] }
where reusing enumNameToValue
can save some computationCLOVIS
06/12/2024, 8:31 AMentries.find {}
is probably still faster, and uses a lot less memory; but yeah if you have a big enum this is better