(thread ^^^)
# javascript
b
(thread ^^^)
d
Regarding to that, the newtype approach woldnt allow exhaustiveness checks. Though in some cases i use those int-like enums as bit fields: const enum
Foo { bitone = 0b001, bittwo = 0b010 ... }
. In C# you can mark an enum like that. In the end you do things like:
Foo.one | Foo.two
and you still have a
Foo
b
it’s interesting case, we should keep it in mind when design the feature
d
Cool 👍
b
For interop you can try something like:
Copy code
external sealed class MyEnum {
    object Foo : MyEnum
    object Bar : MyEnum
}

fun MyEnum.toInt() = this.unsafeCast<Int>()
// TODO check that we have such entry and throw if overwise
fun Int.toMyEnum() = this.unsafeCast<MyEnum>()
d
I see. But im coding in kotlin-common. In my case the interop layer is really thin. But good to know. I will try if i have to do something like that in js 👍