Skip to content

Operators

OperatorDescriptionExample
+Adds two numeric values or concatenates text.numero total = a + b
-Subtracts the second operand from the first.entero diferencia = a - b
*Multiplication.entero producto = a * b
/Division. For integers, division is integer division.entero cociente = a / b
%Remainder or modulo.entero residuo = a % b
entero suma = 5 + 3
texto combinado = "Hola" + " Quetzal"
OperatorDescription
==Equality.
!=Inequality.
>Greater than.
<Less than.
>=Greater than or equal.
<=Less than or equal.
log es_mayor = 10 > 5
log es_igual = "texto" == "texto"

Quetzal supports both symbolic operators (&&, ||, !) and their Spanish equivalents (y, o, no).

log acceso = (usuario.autenticado y !usuario.bloqueado)
log disponible = (stock > 0) o (pedido_en_camino == verdadero)
log negado = no acceso

Non-boolean values are automatically converted to log following interpreter rules (e.g., empty lists are falso).

OperatorDescription
=Simple assignment.
+=Add and assign.
-=Subtract and assign.
*=Multiply and assign.
/=Divide and assign.
%=Calculate remainder and assign.
entero var acumulado = 0
acumulado += 5
acumulado -= 2

The ++ and -- operators are available in postfix form.

entero var contador = 0
contador++
contador--

The form condition ? value_if_true : value_if_false is available for quick evaluations.

entero numero = -10
entero absoluto = numero < 0 ? -numero : numero

Lists and jsn values provide methods instead of specific operators. For example, lista.concatenar(otra_lista) or json.fusionar(otro_json). See the data types sections for more information.

  1. Function calls and member access.
  2. Unary operators (no, !, ++, --).
  3. Multiplication and division.
  4. Addition and subtraction.
  5. Comparisons.
  6. Logical operators (y, o).
  7. Assignments (=, +=, etc.).

Use parentheses to clarify intent when combining multiple operators.

// Arithmetic operators
entero suma(entero a, entero b) {
retornar a + b
}
entero resta(entero a, entero b) {
retornar a - b
}
// Logical operators
log es_verdadero(log valor) {
retornar valor
}
log es_falso(log valor) {
retornar !valor
}
// Comparison operators
log es_igual(entero a, entero b) {
retornar a == b
}
log es_diferente(entero a, entero b) {
retornar a != b
}
log es_mayor(entero a, entero b) {
retornar a > b
}
log es_menor(entero a, entero b) {
retornar a < b
}
// Compound operators
entero suma_compuesta(entero var valor, entero incremento) {
valor += incremento
retornar valor
}
// Run functions to test operators
entero resultado_suma = suma(5, 10)
entero resultado_resta = resta(10, 5)
log resultado_es_igual = es_igual(5, 5)
entero resultado_suma_compuesta = suma_compuesta(5, 10)