Skip to content

Operators Reference

OperatorDescriptionExample
+Additiona + b
-Subtraction / negationa - b, -x
*Multiplicationa * b
/Divisiona / b
%Moduloa % b

All comparisons compile to strict equality (===, !==).

OperatorDescriptionCompiles to
==Equal===
!=Not equal!==
<Less than<
>Greater than>
<=Less or equal<=
>=Greater or equal>=
OperatorDescriptionExample
&&Logical ANDa && b
||Logical ORa || b
!Logical NOT!a
OperatorDescriptionExample
|>Pipex |> f

The pipe operator passes the left side as the first argument to the right side. Use _ as a placeholder for non-first-argument positions.

x |> f // f(x)
x |> f(a, _) // f(a, x)
x |> f |> g // g(f(x))
x |> match { ... } // match x { ... }
OperatorDescriptionExample
?Unwrap Result/Optionexpr?

The ? operator unwraps Ok(value) or Some(value), and returns early with Err(e) or None on failure. Only valid inside functions that return Result or Option.

OperatorContextMeaning
fn(x)Closuresfn(x) x + 1
.fieldDot shorthand.name (implicit field-access closure)
->Match arms, return types, function typesOk(x) -> x, fn(string) -> number
|>Pipesdata |> transform
  1. Unary: !, -
  2. Multiplicative: *, /, %
  3. Additive: +, -
  4. Comparison: <, >, <=, >=
  5. Equality: ==, !=
  6. Logical AND: &&
  7. Logical OR: ||
  8. Pipe: |>
  9. Unwrap: ?