is there a way to do expect/actual for enums?
# multiplatform
l
is there a way to do expect/actual for enums?
d
Yes, e are you experiencing any issues?
l
I dont know how to do it. I have ios variables that are longs and ios variables that are ints, i want to unify them somehow. How do I define it?
d
Expect the enum name and entry names, then you do an actual for the implementation. I'd type up an example if I was at my computer.
l
could you do that, once you do get to your computer ?
d
Sure
l
thx
c
Maybe something like:
Copy code
// Common
enum class MyEnum {
  V1,
  V2
}
expect MyEnum.value: Number
Copy code
// iOS
actual MyEnum.value: Int
  get = when (this) {
    V1 -> 1
    V2 -> 2
  }
l
thx, its working
d
Copy code
expect enum class MyEnum {
    V1, V2;
}

actual enum class MyEnum(val value: Int) {
    V1(0), V2(1);
}

actual enum class MyEnum(val value: Long) {
    V1(0), V2(1);
}
241 Views