https://kotlinlang.org logo
#stdlib
Title
# stdlib
j

jw

11/01/2017, 9:43 PM
actually i'm not even sure it should exist
k

karelpeeters

11/01/2017, 11:22 PM
Isn't there
EnumSet.of
already in the Java standard library?
j

jw

11/01/2017, 11:24 PM
Kotlin runs on more than Java!
k

karelpeeters

11/01/2017, 11:26 PM
Right, I've been trying out Kotlin-JS for a while now and I still seem to forget 🙄.
j

jw

11/01/2017, 11:33 PM
you can't mostly use
setOf
, but the
all
case isn't covered
k

karelpeeters

11/01/2017, 11:40 PM
setOf(*MyEnum.values())
, could be cleaner of course.
(I believe you've made a typo)
j

jw

11/01/2017, 11:43 PM
true
so maybe it's all covered
MyEnum.values().toSet()
k

kevinmost

11/02/2017, 12:23 AM
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

jw

11/02/2017, 12:28 AM
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

kevinmost

11/02/2017, 1:07 AM
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
2 Views