Hyperlinkv0.8.0-beta.28

Boolean

Boolean.xorconsteffect/Boolean.ts:315
(that: boolean): (self: boolean) => boolean
(self: boolean, that: boolean): boolean

Combines two booleans using XOR: (!self && that) || (self && !that).

When to use

Use to accept when exactly one boolean operand is true.

Example (Combining booleans with XOR)

import { Boolean } from "effect"
import * as assert from "node:assert"

assert.deepStrictEqual(Boolean.xor(true, true), false)
assert.deepStrictEqual(Boolean.xor(true, false), true)
assert.deepStrictEqual(Boolean.xor(false, true), true)
assert.deepStrictEqual(Boolean.xor(false, false), false)
combinators
Source effect/Boolean.ts:3154 lines
export const xor: {
  (that: boolean): (self: boolean) => boolean
  (self: boolean, that: boolean): boolean
} = dual(2, (self: boolean, that: boolean): boolean => (!self && that) || (self && !that))
Referenced by 1 symbols