Skip to content

Operators

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

RayQuiro features a full set of operators for arithmetic, logic, null-safety, and assignment.


OperatorMeaningExampleResult
+Addition / String Concat10 + 5, "a" + "b"15, "ab"
-Subtraction / Negation10 - 4, -x6
*Multiplication6 * 742
/Division (floating point)10 / 42.5
%Modulo (remainder)10 % 31

Comparisons evaluate to boolean true or false:

OperatorMeaningExample
==Equalityx == 10
!=Inequalityx != 0
<Less thanscore < 50
<=Less than or equalcount <= 10
>Greater thanhealth > 0
>=Greater than or equallevel >= 18

OperatorNameBehavior
&&Logical ANDReturns truthy if both operands are truthy. Short-circuits.
||Logical ORReturns truthy if either operand is truthy. Short-circuits.
!Logical NOTInverts truthiness (!true is false, !0 is true).
if (user != null && user["is_admin"] && user["level"] >= 10) {
grant_access();
}

Returns the right-hand operand when the left-hand operand is null:

var username = input_name ?? "Guest";

Safely accesses nested properties or indices without crashing if intermediate values are null:

var server_host = config?.["network"]?.["host"] ?? "127.0.0.1";

OperatorMeaningEquivalent
=Simple assignmentx = 5
+=Add and assignx = x + 2
-=Subtract and assignx = x - 2
*=Multiply and assignx = x * 2
/=Divide and assignx = x / 2

RayQuiro also supports lvalue indexed assignment on collections:

inventory[0] = "Shield";
player["health"] = 100;