The Or Logical Operator is used to combine two Boolean expressions together. The Or operator evaluates to True if at least one side is True. It only evaluates to False when both the left side and the right side are False.
The short syntax structure uses the || symbol:
VALUE || VALUEThe long syntax structure uses the word OR:
VALUE OR VALUEThe Or operator follows this logic:
PRINTLN TRUE || TRUE // Displays "TRUE"
PRINTLN TRUE || FALSE // Displays "TRUE"
PRINTLN FALSE || TRUE // Displays "TRUE"
PRINTLN FALSE || FALSE // Displays "FALSE"NEW BOOL result1 = TRUE || FALSE
NEW BOOL result2 = FALSE || TRUE
NEW BOOL result3 = FALSE || FALSE
PRINTLN result1 // Displays "TRUE"
PRINTLN result2 // Displays "TRUE"
PRINTLN result3 // Displays "FALSE"NEW BOOL hasTicket = TRUE
NEW BOOL hasInvite = FALSE
NEW BOOL canEnter = hasTicket || hasInvite
PRINTLN canEnter // Displays "TRUE"NEW BOOL isWeekend = FALSE
NEW BOOL isHoliday = TRUE
NEW BOOL isDayOff = isWeekend || isHoliday
PRINTLN isDayOff // Displays "TRUE"The Or operator is commonly used to combine multiple Comparison Operators.
NEW STR grade = "A"
NEW BOOL isTopGrade = ( grade == "A") || ( grade == "B" )
PRINTLN isTopGrade // Displays "TRUE"NEW INT value = 150
NEW BOOL outOfRange = ( value < 0 ) || ( value > 100 )
PRINTLN outOfRange // Displays "TRUE"NEW INT score = 55
NEW BOOL hasExtraCredit = TRUE
NEW BOOL passes = ( score >= 60 ) || hasExtraCredit
PRINTLN passes // Displays "TRUE"The Or operator is frequently used in If statements to check if any condition is met.
NEW BOOL isAdmin = FALSE
NEW BOOL isModerator = TRUE
IF isAdmin || isModerator
PRINTLN "Access granted"
ELSE
PRINTLN "Access denied"
END IF
// Displays "Access granted"NEW STR answer = "yes"
IF ( answer == "yes" ) || ( answer == "y" ) || ( answer == "YES" )
PRINTLN "Confirmed"
ELSE
PRINTLN "Not confirmed"
END IF
// Displays "Confirmed"NEW INT statusCode = 404
IF ( statusCode == 404 ) || ( statusCode == 500 ) || ( statusCode == 503 )
PRINTLN "Error occurred"
ELSE
PRINTLN "Request successful"
END IF
// Displays "Error occurred"The Or operator can control loop continuation by allowing any condition to keep the loop running.
NEW INT counter = 1
NEW BOOL maxReached = FALSE
WHILE ( counter <= 10 ) || ( maxReached == FALSE )
PRINTLN "Iteration: " .. counter
SET counter = counter + 1
IF counter > 5
SET maxReached = TRUE
BREAK
END IF
END WHILE
// Displays: Iteration: 1, Iteration: 2, Iteration: 3, Iteration: 4, Iteration: 5NEW INT i = 1
NEW BOOL found = FALSE
WHILE ( i <= 10 ) || found
IF i == 7
SET found = TRUE
PRINTLN "Found target at: " .. i
BREAK
END IF
SET i = i + 1
END WHILEYou can chain multiple Or operators to check if any condition is True.
NEW STR color = "blue"
NEW BOOL isPrimary = ( color == "red" ) || ( color == "blue" ) || ( color == "yellow" )
PRINTLN isPrimary // Displays "TRUE"NEW STR status = "pending"
NEW BOOL isActive = ( status == "active" ) || ( status == "pending" ) || ( status == "processing" )
PRINTLN isActive // Displays "TRUE"NEW INT temp = 105
NEW INT pressure = 80
NEW INT vibration = 30
NEW BOOL alertNeeded = ( temp > 100 ) || ( pressure > 90 ) || ( vibration > 50 )
IF alertNeeded == TRUE
PRINTLN "System alert triggered"
ELSE
PRINTLN "All systems normal"
END IF
// Displays "System alert triggered"NEW STR dayOfWeek = "Saturday"
NEW BOOL isHoliday = FALSE
NEW BOOL isDayOff = ( dayOfWeek == "Saturday" ) || ( dayOfWeek == "Sunday" ) || isHoliday
IF isDayOff == TRUE
PRINTLN "No work today!"
ELSE
PRINTLN "Work day"
END IF
// Displays "No work today!"NEW BOOL hasCash = FALSE
NEW BOOL hasCard = TRUE
NEW BOOL hasDigitalWallet = FALSE
NEW BOOL canPay = hasCash || hasCard || hasDigitalWallet
IF canPay == TRUE
PRINTLN "Payment method available"
ELSE
PRINTLN "No payment method"
END IF
// Displays "Payment method available"NEW BOOL isStudent = TRUE
NEW BOOL isSenior = FALSE
NEW BOOL isMilitary = FALSE
NEW BOOL getsDiscount = isStudent || isSenior || isMilitary
IF getsDiscount == TRUE
PRINTLN "Discount applied"
ELSE
PRINTLN "Regular price"
END IF
// Displays "Discount applied"NEW BOOL fireDanger = FALSE
NEW BOOL floodWarning = TRUE
NEW BOOL hurricaneAlert = FALSE
NEW BOOL evacuate = fireDanger || floodWarning || hurricaneAlert
IF evacuate == TRUE
PRINTLN "Emergency evacuation required"
ELSE
PRINTLN "No evacuation needed"
END IF
// Displays "Emergency evacuation required"The Or operator requires at least one condition to be True, while the And operator requires all conditions to be True.
NEW BOOL a = TRUE
NEW BOOL b = FALSE
PRINTLN a || b // Displays "TRUE" (at least one is TRUE)
PRINTLN a && b // Displays "FALSE" (both must be TRUE)NEW BOOL hasTicket = TRUE
NEW BOOL hasInvite = FALSE
NEW BOOL canEnterOr = hasTicket || hasInvite
NEW BOOL canEnterAnd = hasTicket && hasInvite
PRINTLN canEnterOr // Displays "TRUE" (either works)
PRINTLN canEnterAnd // Displays "FALSE" (needs both)You can combine Or and And operators to create complex logical expressions. Use parentheses to control the order of evaluation.
NEW INT age = 25
NEW BOOL hasLicense = TRUE
NEW BOOL hasPermit = FALSE
NEW BOOL canDrive = ( age >= 18 ) && ( hasLicense || hasPermit )
PRINTLN canDrive // Displays "TRUE"NEW BOOL isMember = FALSE
NEW BOOL isVIP = TRUE
NEW FLOAT purchaseAmount = 50.0
NEW BOOL getsDiscount = ( isMember || isVIP ) && ( purchaseAmount >= 25.0 )
PRINTLN getsDiscount // Displays "TRUE"NEW BOOL hasKeyA = TRUE
NEW BOOL hasKeyB = FALSE
NEW BOOL hasKeyC = FALSE
NEW BOOL unlocked = ( hasKeyA || hasKeyB ) && ( hasKeyA || hasKeyC )
PRINTLN unlocked // Displays "TRUE"When using Or, if the left side is True, the result is always True regardless of the right side. This is called short-circuit evaluation.
NEW BOOL checkFirst = TRUE
NEW BOOL checkSecond = FALSE
NEW BOOL result = checkFirst || checkSecond
PRINTLN result // Displays "TRUE" (first condition passed, second doesn't matter)NEW STR input = "y"
NEW BOOL isYes = ( input == "yes" ) || ( input == "y" ) || ( input == "Y" ) || ( input == "YES" )
PRINTLN isYes // Displays "TRUE"NEW BOOL task1 = TRUE
NEW BOOL task2 = FALSE
NEW BOOL task3 = TRUE
NEW BOOL anyIncomplete = ( task1 == FALSE ) || ( task2 == FALSE ) || ( task3 == FALSE )
IF anyIncomplete == TRUE
PRINTLN "Some tasks incomplete"
ELSE
PRINTLN "All tasks complete"
END IF
// Displays "Some tasks incomplete"NEW BOOL route1Open = FALSE
NEW BOOL route2Open = TRUE
NEW BOOL route3Open = FALSE
NEW BOOL canProceed = route1Open || route2Open || route3Open
IF canProceed == TRUE
PRINTLN "Path available"
ELSE
PRINTLN "All routes blocked"
END IF
// Displays "Path available"NEW BOOL option1 = FALSE
NEW BOOL option2 = FALSE
NEW BOOL hasOption = option1 || option2
PRINTLN hasOption // Displays "FALSE"NEW BOOL qualified1 = FALSE
NEW BOOL qualified2 = FALSE
NEW BOOL qualified3 = FALSE
NEW BOOL isQualified = qualified1 || qualified2 || qualified3
IF isQualified == TRUE
PRINTLN "Qualified"
ELSE
PRINTLN "Not qualified"
END IF
// Displays "Not qualified"NEW INT x = 5
NEW INT y = 10
PRINTLN x || y // Type error! Or requires Boolean valuesNEW STR status = "active"
// Wrong: Missing comparison
// IF status || "pending" // Syntax error!
// Correct: Use comparison operators
IF ( status == "active" ) || ( status == "pending" )
PRINTLN "Valid status"
END IFNEW BOOL hasTicket = TRUE
NEW BOOL hasInvite = FALSE
// Or allows either (correct if you only need one)
IF hasTicket || hasInvite
PRINTLN "Can enter"
END IF
// And requires both (wrong if you only need one)
IF hasTicket && hasInvite
PRINTLN "Can enter"
END IF
// Displays "Can enter"NEW BOOL a = TRUE
NEW BOOL b = FALSE
NEW BOOL c = TRUE
// Ambiguous without parentheses
NEW BOOL result1 = a && b || c
// Clear with parentheses
NEW BOOL result2 = ( a && b ) || c
NEW BOOL result3 = a && ( b || c )
PRINTLN result2 // Displays "TRUE"
PRINTLN result3 // Displays "TRUE"