Hi hivemind. I have an optimisation question. I have a
fun mainFun(): Either<A, B>
where A is a sealed interface. I then call this within another function
fun caller(): Either<A, B?>
whose goal is to check if the called
mainFun
returns left and if so, depending on the type of the left, return B? or A. It always return B if
mainFun
returns B.
Currently I’m using fold like the below, so I’m wondering if there’s a better way to do that?
return mainFun().fold({if(it == SpecialSealedImpl} null.right else it.left) { it.right }