arrow-core-data / arrow.core / Ior / fold

fold

inline fun <C> fold(fa: (A) -> C, fb: (B) -> C, fab: (A, B) -> C): C

Applies fa if this is a Left, fb if this is a Right or fab if this is a Both

Example:

val result: Ior<EmailContactInfo, PostalContactInfo> = obtainContactInfo()
result.fold(
     { log("only have this email info: $it") },
     { log("only have this postal info: $it") },
     { email, postal -> log("have this postal info: $postal and this email info: $email") }
)

Parameters

fa - the function to apply if this is a Left

fb - the function to apply if this is a Right

fab - the function to apply if this is a Both

Return the results of applying the function

Do you like Arrow?

Arrow Org
<