July 2018
Intermediate to advanced
242 pages
8h 6m
English
In order to overload the operator for the specific type, we need to provide a member function or an extension function with a fixed name corresponding to the operator. Additionally, functions that overload operators need to be marked with the operator keyword.
In the following tables, you can find grouped sets of operators available in the language with their corresponding expressions to which they are translated to:
Unary prefix
| Operator | Expression |
| +a | a.unaryPlus() |
| -a | a.unaryMinus() |
| !a | a.not() |
Incrementation and decrementation
| Operator | Expression |
| a++ | a.inc() |
| a-- | a.dec() |
Arithmetic
| Operator | Expression |
| a + b | a.plus(b) |
| a - b | a.minus(b) |
| a * b | a.times(b) |
| a / b | a.div(b) |
| a % b | a.rem(b) |
| a..b ... |
Read now
Unlock full access