question: is there any case where `values()`<https...
# language-evolution
d
question: is there any case where `values()` is preferable to `enum.entries` after Kotlin 1.9?
I do not know if this is the proper channel for this, or this is more for potential future changes
k
The only reason I can think of when you might need
values()
is if you need to call a function that takes an array of enums. If
values()
didn't exist, you'd have to use
entries.toTypedArray()
. However, I think such a use case would be extremely rare.
👍 2
e
you aren't losing anything in that case anyway: both
values()
and
entries.toTypedArray()
construct a new
Array<Enum>
I can imagine that you might not be able to use
entries
if you are a library building with a newer Kotlin while targeting an older Kotlin's API, or expressly want to avoid kotlin-stdlib dependencies for shrinking purposes (e.g. https://jakewharton.com/shrinking-a-kotlin-binary/)
👍 2