fold
Applies ifLeft if this is a Left or ifRight if this is a Right.
Example:
import arrow.core.*
fun main() {
fun possiblyFailingOperation(): Either.Right<Int> =
Either.Right(1)
//sampleStart
val result: Either<Exception, Int> = possiblyFailingOperation()
result.fold(
{ println("operation failed with $it") },
{ println("operation succeeded with $it") }
)
//sampleEnd
}Content copied to clipboard
Return
the results of applying the function