Skip to content

Operators

Arithmetic

OperatorDescriptionExampleResult
+Addition3 + 47
-Subtraction10 - 37
*Multiplication6 * 742
/Division10 / 33.33
%Modulo10 % 31
-Negation-5-5

+ also concatenates strings:

zink
say "hello" + " " + "world"   # hello world

Comparison

OperatorDescriptionExampleResult
==Equal5 == 5true
!=Not equal5 != 3true
<Less than3 < 5true
>Greater than5 > 3true
<=Less or equal5 <= 5true
>=Greater or equal3 >= 5false

Comparison works on numbers and strings (lexicographic for strings).

Logical

OperatorDescriptionExampleResult
andLogical ANDtrue and falsefalse
orLogical ORfalse or truetrue
notLogical NOTnot truefalse

Assignment

OperatorDescriptionExample
=Assignx = 42

There are no compound assignment operators (+=, -=, etc.) in v0.1.0.

Precedence

From highest to lowest:

  1. Unary: not, - (negation)
  2. Multiplicative: *, /, %
  3. Additive: +, -
  4. Comparison: <, >, <=, >=
  5. Equality: ==, !=
  6. Logical AND: and
  7. Logical OR: or
  8. Assignment: =

Parentheses override precedence:

zink
say (1 + 2) * 3   # 9
say 1 + 2 * 3     # 7

Released under the MIT License.