Logical Functions (5)
Boolean logic operations
and
Logical and. Test whether two values are both defined with a nonzero/nonempty value.
Syntax
x and y | and(x | y)
Type Signatures
Complex, Complex, BigNumber, BigNumber
Parameters
Name Type Description
x number | BigNumber | bigint | Complex | Unit | Array | Matrix First value to check
y number | BigNumber | bigint | Complex | Unit | Array | Matrix Second value to check
Returns
boolean | Array | Matrix —
Examples
true and false true and true 2 and 4
not
Logical not. Flips the boolean value of given argument.
Parameters
Name Type Description
x number | BigNumber | bigint | Complex | Unit | Array | Matrix First value to check
Returns
boolean | Array | Matrix —
Examples
not true not false not 2 not 0
nullish
Nullish coalescing operator. Returns the right-hand operand when the left-hand operand is null or undefined, and otherwise returns the left-hand operand.
Syntax
x ?? y | nullish(x | y)
Parameters
Name Type Description
x * First value to check
y * Fallback value
Returns
* — Returns y when x is null or undefined, otherwise returns x
Examples
null ?? 42 undefined ?? 42 0 ?? 42 false ?? 42 null ?? undefined ?? 42
or
Logical or. Test if at least one value is defined with a nonzero/nonempty value.
Syntax
x or y | or(x | y)
Type Signatures
Complex, Complex, BigNumber, BigNumber
Parameters
Name Type Description
x number | BigNumber | bigint | Complex | Unit | Array | Matrix First value to check
y number | BigNumber | bigint | Complex | Unit | Array | Matrix Second value to check
Returns
boolean | Array | Matrix —
Examples
true or false false or false 0 or 4
xor
Logical exclusive or, xor. Test whether one and only one value is defined with a nonzero/nonempty value.
Syntax
x xor y | xor(x | y)
Type Signatures
Complex, Complex, BigNumber, BigNumber
Parameters
Name Type Description
x number | BigNumber | bigint | Complex | Unit | Array | Matrix First value to check
y number | BigNumber | bigint | Complex | Unit | Array | Matrix Second value to check
Returns
boolean | Array | Matrix —
Examples
true xor false false xor false true xor true 0 xor 4