foldSuspend
inline suspend fun <A, B, C> Either<A, B>.foldSuspend(crossinline ifLeft: suspend (A) -> C, crossinline ifRight: suspend (B) -> C): C
Content copied to clipboard
Author
skydoves (Jaewoong Eum)
Since
1.0.1
Applies ifLeft
if this is a Left or ifRight
if this is a Right.
Example:
val result: Either<Exception, Value> = possiblyFailingOperation()
result.fold(
{ log("operation failed with $it") },
{ log("operation succeeded with $it") }
)
Content copied to clipboard
Return
the results of applying the function
Parameters
ifLeft
the function to apply if this is a Left
ifRight
the function to apply if this is a Right