actually i'm not even sure it should exist
# stdlib
j
actually i'm not even sure it should exist
k
Isn't there
EnumSet.of
already in the Java standard library?
j
Kotlin runs on more than Java!
k
Right, I've been trying out Kotlin-JS for a while now and I still seem to forget 🙄.
j
you can't mostly use
setOf
, but the
all
case isn't covered
k
setOf(*MyEnum.values())
, could be cleaner of course.
(I believe you've made a typo)
j
true
so maybe it's all covered
MyEnum.values().toSet()
k
but doesn't that just return you a
Set
, not an
EnumSet
? Wouldn't you want some specialized version that gives you the
EnumSet
?
j
I don't really care that much. I assumed an enumSetOf would just delegate to a normal set on JS or native to start with.
k
Hm, I assume as much too. But wouldn't it be nice to have a method that, when called on JVM, gives you a nice efficient
EnumSet
, and when called elsewhere, gives you just a normal
Set
? Maybe
setOf
could check if the elements it's being passed are `Enum`s and make an
EnumSet
if so. But that doesn't cover the case of creating an empty mutable set, of course