Thread
#stdlib
    j

    jw

    4 years ago
    actually i'm not even sure it should exist
    karelpeeters

    karelpeeters

    4 years ago
    Isn't there
    EnumSet.of
    already in the Java standard library?
    j

    jw

    4 years ago
    Kotlin runs on more than Java!
    karelpeeters

    karelpeeters

    4 years ago
    Right, I've been trying out Kotlin-JS for a while now and I still seem to forget 🙄.
    j

    jw

    4 years ago
    you can't mostly use
    setOf
    , but the
    all
    case isn't covered
    karelpeeters

    karelpeeters

    4 years ago
    setOf(*MyEnum.values())
    , could be cleaner of course.
    (I believe you've made a typo)
    j

    jw

    4 years ago
    true
    so maybe it's all covered
    MyEnum.values().toSet()
    kevinmost

    kevinmost

    4 years ago
    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

    4 years ago
    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.
    kevinmost

    kevinmost

    4 years ago
    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 Enums and make an
    EnumSet
    if so. But that doesn't cover the case of creating an empty mutable set, of course