Skip to content

swap

swap<E, A>(data): These<A, E>

Defined in: Core/These.ts:248

Swaps the roles of error and success values.

  • Err(e) → Ok(e)
  • Ok(a) → Err(a)
  • Both(e, a) → Both(a, e)

E

A

These<E, A>

These<A, E>

These.swap(These.err("err"));        // Ok("err")
These.swap(These.ok(5));             // Err(5)
These.swap(These.both("warn", 5));   // Both(5, "warn")