Below is a detailed explanation of each logical operator provided in the Wave language, designed to support both low-level control and high-level abstraction.
Logical AND &&
The &&
operator performs a logical AND operation, evaluating two conditions.
It returns true
only if both operands are true. Commonly used in conditional statements.
Bitwise AND &
The &
operator performs a bitwise AND operation on two binary values,
returning a binary result where each bit is set to 1 only if the corresponding bits of both operands are 1.
Logical OR ||
The ||
operator performs a logical OR operation, returning true
if at least one operand is true. Often used to check multiple conditions in one expression.
Bitwise OR |
The |
operator performs a bitwise OR operation, returning a binary result where each bit is 1
if any corresponding bit of the operands is 1. Useful for setting specific bits in binary data.
Not Equal !=
The !=
operator checks if two values are not equal, returning true
if they differ.
It’s essential for conditional checks where non-equivalence matters.
Exclusive OR ^
The ^
operator performs an exclusive OR operation, returning true
if only one of the operands is true.
In bitwise form, it sets each bit to 1 if only one of the corresponding bits of the operands is 1.
Exclusive NOR ~^
The ~^
operator performs an exclusive NOR operation, returning true
if both operands are either true or false.
In bitwise operation, it sets each bit to 1 only if both corresponding bits of the operands are the same.
Bitwise NOT ~
The ~
operator inverts each bit in a binary value, turning 1s to 0s and vice versa.
Useful for creating bitwise negations in data manipulation.
Not AND !&
The !&
operator is a logical NAND operation, returning true
if at least one of the operands is false.
This is the negated form of the AND operation.
Not OR !|
The !|
operator performs a logical NOR operation, returning true
only if both operands are false.
It is the negated form of the OR operation.
Logical NOT !
The !
operator negates a single boolean value, converting true
to false
and vice versa.
Often used to reverse a condition's value in control statements.
Null Coalescing ??
The ??
operator returns the right-hand operand if the left-hand operand is null
or undefined.
This operator is useful for setting default values in nullable contexts.
Conditional ?:
The ?:
operator, also known as the ternary operator, allows concise conditional expressions.
It returns one of two values based on a boolean condition: condition ? value_if_true : value_if_false
.
In in
The in
operator checks if an element exists within a collection or sequence.
It returns true
if the element is found, otherwise false
.
Is is
The is
operator checks for strict type or reference equality, useful in type comparisons or when ensuring two values are exactly the same instance.