Logical Operators

← Back to documentation


Operators

Operator Description Truth Table
&& Logical AND 1 && 1 = 1
1 && 0 = 0
0 && 1 = 0
0 && 0 = 0
|| Logical OR 1 || 1 = 1
1 || 0 = 1
0 || 1 = 1
0 || 0 = 0

Examples

Basic usage

print(1 && 1)    # 1
print(1 && 0)    # 0
print(1 || 0)    # 1
print(0 || 0)    # 0

With comparisons

x = 10
y = 20
result = (x > 5) && (y < 30)
print(result)
# Output: 1

result = (x > 15) && (y < 30)
print(result)
# Output: 0

Complex conditions

age = 25
hasLicense = 1
canDrive = (age >= 18) && hasLicense
print(canDrive)
# Output: 1

Short-circuit evaluation

# AND: if left is false, right is not evaluated
x = 0
y = 10
result = (x != 0) && (y / x > 5)  # No division by zero
print(result)
# Output: 0

Truthiness

Any non-zero value is considered true:

print(42 && 1)     # 1 (true)
print(-5 && 0)     # 0 (false)
print(3.14 || 0)   # 1 (true)

See Also


© 2026 elliktronic · Jaf Language