Skip to content

Control Flow

This content is for v1.0. Switch to the latest version for up-to-date documentation.

RayQuiro provides standard control flow statements for branching and looping.


var score = 85;
if (score >= 90) {
print("Grade: A");
} else if (score >= 80) {
print("Grade: B");
} else if (score >= 70) {
print("Grade: C");
} else {
print("Grade: F");
}

Parentheses around the condition are optional or standard, braces {} around the block are required.


The while loop executes its body repeatedly as long as its condition evaluates to a truthy value:

var count = 0;
while (count < 5) {
print("Iteration: " + str(count));
count = count + 1;
}

Terminates the innermost loop immediately:

var i = 0;
while (i < 100) {
if (i == 42) {
print("Found target: 42. Halting loop.");
break;
}
i = i + 1;
}

Skips the remainder of the current iteration and jumps to the next condition evaluation:

var n = 0;
while (n < 10) {
n = n + 1;
if (n % 2 == 0) {
continue;
}
print("Odd number: " + str(n));
}

var fruits = ["apple", "banana", "cherry", "date"];
var idx = 0;
while (idx < len(fruits)) {
var item = fruits[idx];
print("Fruit #" + str(idx + 1) + ": " + item);
idx = idx + 1;
}
---
## 5. Pattern Matching (`match`)
RayQuiro includes pattern matching without fallthrough:
```js
var status = 200;
match status {
200 => print("OK"),
400 => print("Bad Request"),
404 => print("Not Found"),
500 => {
print("Internal Server Error");
log_error("Server down");
},
_ => print("Unknown Status Code")
}
  • Each pattern is evaluated in order; the first match executes and terminates the match construct immediately (no break needed).
  • Use _ (wildcard) or default to handle fallback cases.
  • Both single statement expressions and { ... } code blocks are supported on the right side of =>.