y9san9
07/12/2021, 2:20 PMNothing
type, I was trynna use it with generics in entity like Either
.
sealed interface Either<out TLeft, out TRight> {
class Failure<T>(...) : Either<T, Nothing>
class Success<T>(...) : Result<Nothing, T>
}
This is cool approach in Kotlin and everything works fine:
val result: Either<Entity, Error> = result as Success<Entity>
BUT in swift I can't do stuff like this:
guard let result: Either<Entity, Error> = result as? Success<Entity> else { return }
This will break at runtime, since swift generics aren't erased, and it won't pass type check (Nothing
!= Error
). Any ideas how to workaround it?
cc @alex009y9san9
07/12/2021, 2:21 PM