Web Home
Getting Started
Manual
Packages
Quick Reference
Language Reference
Function Reference
I/O Reference

- Language Reference
  - Starting and Quitting Yorick
  - Getting Help
  - Error Recovery
  - Array Data Types
  - Constants
  - Defining Variables
  - Arithmetic and Comparison Operators
  - Logical Operators
  - Creating Arrays
  - Indexing Arrays
  - Array Conformability Rules
  - Calling Functions
  - Defining Functions
  - Variable Scope
  - Returning from Functions
  - Compound Statements
  - Conditional Execution
  - Loops
- Function Reference
- I/O Reference

# Yorick Language Reference

## Logical Operators

Yorick supports C-style logical AND and OR operators. Unlike the arithmetic and comparison operators, these take only scalar operands and return a scalar `int` result. Their precedence is between `|` and `=`.

The right operand is not evaluated at all if the value of the left operand decides the result value; hence the left operand may be used to determine whether the evaluation of the right operand would lead to an error.

`&&` logical and (scalar `int` result)
`||` logical or (scalar `int` result)

The logical NOT operator takes an array or a scalar operand, returning `int` 1 if the operand was zero, 0 otherwise. Its precedence is above `^`.

`!` logical not (`int` result)

The ternary operator selects one of two values based on the value of a scalar condition:

condition `?` true_expr `:` false_expr

Its precedence is low, and it must be parenthesized in a function argument list or an array index list to prevent confusion with the `:` in the index range syntax. Like `&&` and `||`, the expression which is rejected is not evaluated at all.