7 months ago
    I have a custom result-like class that has served me well in kotlin/android;
    sealed class Resolved<out T> {
        data class Success<out T>(val data: T) : Resolved<T>()
        data class Error(val exception: Exception) : Resolved<Nothing>()
    But in case of Error, how can I extract the exception on the iOS side? If Resolved.Error has a type parameter (Error<T>) i can do in swift:
    *let* val = response *as*? ResolvedError { ...
    But when it doesnt and is typed as Resolved<Nothing> I cannot. Or at least I don't know how. Any tips?
    actually this can trivially solved on the kt side by doing e.g.
    fun <T> Resolved<T>.errorOrNull() = (this as? Resolved.Error)?.exception
    and in swift
    *let* val = response?.errorOrNull() {
    print("Found an exception \(val)")