Skip to content

Control Flow

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;
}

RayQuiro includes pattern matching with range support and conditional guards without fallthrough:

var status = 200;
match (status) {
200 => print("OK"),
400..499 => print("Client Error"),
500..599 if status != 503 => print("Server Error"),
503 => print("Service Unavailable"),
_ => print("Unknown Status Code")
}
  • Ranges (start..end): Match values inclusive of boundaries (e.g. 1..9 or 400..499).
  • Pattern Guards (if condition): Execute arm only if both the pattern and the guard condition are satisfied.
  • Wildcard (_): Match all fallback cases.
  • Both single statements and { ... } blocks are supported after =>.