//arrow-core/arrow.core/Either/swap

swap

common fun swap(): Either<B, A>

If this is a Left, then return the left value in Right or vice versa.

Example:

import arrow.core.*

fun main() {
  Either.Left("left").swap()   // Result: Right("left")
  Either.Right("right").swap() // Result: Left("right")
}

Do you like Arrow?

Arrow Org
<