-
Notifications
You must be signed in to change notification settings - Fork 1
Operators
Lloyd Dilley edited this page Aug 26, 2021
·
7 revisions
Operator | Arity | Type | Description | Example |
---|---|---|---|---|
+ | binary | mathematical | add | 1 + 2 |
- | binary | mathematical | subtract | 2 - 1 |
/ | binary | mathematical | divide | 2 / 1 |
* | binary | mathematical | multiply | 1 * 2 |
% | binary | mathematical | modulo | 3 % 2 |
** | binary | mathematical | exponent | 2**2 |
++ | unary | mathematical | increment | amount++ |
-- | unary | mathematical | decrement | amount-- |
! | unary | logical | not/negation | !alive |
&& | binary | logical | and | health == 0 && lives == 0 |
|| | binary | logical | or | ammo.full || clip.full |
== | binary | relational | equal to | count == 1 |
!= | binary | relational | not equal to | name != "Joe" |
$= | binary | relational | string length equal to | "foo" $= "bar" |
$! | binary | relational | string length not equal to | "foo" $! "bar" |
< | binary | relational | less than | level < 10 |
> | binary | relational | greater than | skill > 0 |
<= | binary | relational | less than or equal to | score <= 999 |
>= | binary | relational | greater than or equal to | health >= 1 |
& | binary | bitwise | and | 0 & 1 |
| | binary | bitwise | or | 0 | 1 |
^ | binary | bitwise | xor | 0 ^ 1 |
~ | unary | bitwise | not/ones' complement | ~32 |
<< | binary | bitwise | shift left | 0001 << 1 |
>> | binary | bitwise | shift right | 0010 >> 1 |
= | binary | assignment | assign value | x = 1 |
+= | binary | assignment | add and assign | x += 1 |
-= | binary | assignment | subtract and assign | x -= 1 |
/= | binary | assignment | divide and assign | x /= 1 |
*= | binary | assignment | multiply and assign | x *= 1 |
%= | binary | assignment | modulo and assign | x %= 1 |
**= | binary | assignment | exponentiate and assign | 2 **= 2 |
. | binary | N/A | dot/member access | player.name |