Helios language/

Operators

The following operators are defined on many of the builtins:

OperatorPrecedenceTypeAssociativity
... (...)9callleft-to-right
.9memberleft-to-right
-8unaryright-to-left
+8unaryright-to-left
!8unaryright-to-left
%7binaryleft-to-right
/7binaryleft-to-right
*7binaryleft-to-right
-6binaryleft-to-right
+6binaryleft-to-right
>=5binaryleft-to-right
>5binaryleft-to-right
<=5binaryleft-to-right
<5binaryleft-to-right
!=4binaryleft-to-right
==4binaryleft-to-right
&&3binaryleft-to-right
||2binaryleft-to-right
|1binaryleft-to-right
...=...;...0ternaryN/A

Note: == and != do a deep comparison and are defined automatically on all user-defined and builtin types.

Pipe operator

The pipe operator (|) applies a function value on the right to a value on the left:

func filter_even(lst: []Int) -> []Int {
    lst.filter((item: Int) -> {item%2 == 0})
}

even: []Int = []Int{1,2,3,4} | filter_even; // []Int{2, 4}

If the pipe operator is followed by a binary operator, that binary operator is treated as a partially applied function:

x: Int = 1 + 2 | * 3; // 9

This can be especially convenient in cases with long chains.