Hi all. Does anyone here know why `Kotlin.Result<T...
# ios
x
Hi all. Does anyone here know why
Kotlin.Result<T>
types doesn't get exposed to objective c? I have a kotlin signature that looks like
Copy code
fun example(): Result<Unit> = Result.success(Unit)
which gets exposed as
Copy code
- (id _Nullable)example __attribute__((swift_name("example()")));
in objective-c
Digging down the slack history, i found this from @Bernd Prünster https://github.com/a-sit-plus/KmmResult and its cool but i'm wondering if this is bug/feature is documented anywhere?
f
Not a bug, in-line function are not supported
The alternative way is using kotlin sealed class as enum
x
Sorry, where is the inline function? 🤔
f
Result itself (... inline class, but same effect)
x
ah right - keep forgetting that the
Results
are inline classes
thanks
f
Then you can use the kmmResult lib or sealed class managing the result value.
b
Just beware that both sealed classes and KmmResult introduce instantiation overhead. On a related note:
runCatching
will catch errors you don't want to have caught, which is why KmmResult relies on Arrow's nonFatalOrThrow