arrow-core-data / arrow.core / Either / fold
inline fun <C> fold(ifLeft: (A) -> C, ifRight: (B) -> C): C
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") }
)
ifLeft - the function to apply if this is a Left
ifRight - the function to apply if this is a Right
Return the results of applying the function
Do you like Arrow?
✖