Appendix B: Operators
Tokay implements the following operators for use in expressions. The operators are ordered by precedence, operators in the same row share the same precedence.
Don't confuse with some rows which look as redundant, this depends on either the operator is delimited by whitespace from its operands or not.
Operator | Description | Associativity |
---|---|---|
= += -= *= /= //= %= |
Assignment, combined operation-assignment | left |
|| | Logical or | left |
&& | Logical and | left |
== != < <= >= > |
Equal, unequal, comparison | left |
+ - |
Add, subtract | left |
* / // % |
Multiply, divide, integer divide, modulo | left |
- ! |
Negate, not | right |
++ -- |
Increment, decrement | right |
(...) | Inline sequence | left |
(...) [...] . |
Call parameters, subscript, attribute | left |
Operators produce different results depending on the data-types of their operands. For example, 3 * 10
multiplies 10 by 3, whereas 3 * "test"
creates a new string repeating "test" 3 times. Try out the results of different operands in a Tokay REPL for clarification.