Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Literals and Operators

Literals and operators are written the same way in every language, except true and false, which have their own spellings.

Literals

LiteralMeaning
42, 3.14Number. Every number is a 64-bit float. There is no hex or exponent form.
"hello"Text. Double quotes only. Escapes: \n \t \r \" \\ \0. No interpolation.
true, falseBoolean
()Unit, the “nothing” value
[1, "two", 3.0]List; mixed types, indexed from 0
0..5Range, half-open: 0, 1, 2, 3, 4. Used with for.
|x| x + 1Function value (closure)
ok(v), bad(e)Result values

There are no character, map or tuple literals.

Booleans in each language

English中文日本語한국어ไทย
true真真참จริง
false假偽거짓เท็จ

Operators

From the tightest binding to the loosest:

OperatorMeaning
. () [] :: ..Field or method, call, index, path, range
-x !xNegate, logical not
* / %Multiply, divide, remainder
+ -Add, subtract. + also joins text.
== != < > <= >=Compare
&&Logical and
||Logical or

Other symbols: = in bind name = value, => between a pattern and its result in match, and -> before a return type (parsed and ignored). In the interpreter, && and || always evaluate both sides. See Known Limits.