|
2 | 2 | Cheatsheet
|
3 | 3 | **********
|
4 | 4 |
|
5 |
| -.. index:: precedence |
6 |
| - |
7 |
| -.. _order: |
| 5 | +.. index:: operator; precedence |
8 | 6 |
|
9 | 7 | Order of Precedence of Operators
|
10 | 8 | ================================
|
11 | 9 |
|
12 |
| -The following is the order of precedence for operators, listed in order of evaluation. |
13 |
| - |
14 |
| -+------------+-------------------------------------+--------------------------------------------+ |
15 |
| -| Precedence | Description | Operator | |
16 |
| -+============+=====================================+============================================+ |
17 |
| -| *1* | Postfix increment and decrement | ``++``, ``--`` | |
18 |
| -+ +-------------------------------------+--------------------------------------------+ |
19 |
| -| | New expression | ``new <typename>`` | |
20 |
| -+ +-------------------------------------+--------------------------------------------+ |
21 |
| -| | Array subscripting | ``<array>[<index>]`` | |
22 |
| -+ +-------------------------------------+--------------------------------------------+ |
23 |
| -| | Member access | ``<object>.<member>`` | |
24 |
| -+ +-------------------------------------+--------------------------------------------+ |
25 |
| -| | Function-like call | ``<func>(<args...>)`` | |
26 |
| -+ +-------------------------------------+--------------------------------------------+ |
27 |
| -| | Parentheses | ``(<statement>)`` | |
28 |
| -+------------+-------------------------------------+--------------------------------------------+ |
29 |
| -| *2* | Prefix increment and decrement | ``++``, ``--`` | |
30 |
| -+ +-------------------------------------+--------------------------------------------+ |
31 |
| -| | Unary minus | ``-`` | |
32 |
| -+ +-------------------------------------+--------------------------------------------+ |
33 |
| -| | Unary operations | ``delete`` | |
34 |
| -+ +-------------------------------------+--------------------------------------------+ |
35 |
| -| | Logical NOT | ``!`` | |
36 |
| -+ +-------------------------------------+--------------------------------------------+ |
37 |
| -| | Bitwise NOT | ``~`` | |
38 |
| -+------------+-------------------------------------+--------------------------------------------+ |
39 |
| -| *3* | Exponentiation | ``**`` | |
40 |
| -+------------+-------------------------------------+--------------------------------------------+ |
41 |
| -| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` | |
42 |
| -+------------+-------------------------------------+--------------------------------------------+ |
43 |
| -| *5* | Addition and subtraction | ``+``, ``-`` | |
44 |
| -+------------+-------------------------------------+--------------------------------------------+ |
45 |
| -| *6* | Bitwise shift operators | ``<<``, ``>>`` | |
46 |
| -+------------+-------------------------------------+--------------------------------------------+ |
47 |
| -| *7* | Bitwise AND | ``&`` | |
48 |
| -+------------+-------------------------------------+--------------------------------------------+ |
49 |
| -| *8* | Bitwise XOR | ``^`` | |
50 |
| -+------------+-------------------------------------+--------------------------------------------+ |
51 |
| -| *9* | Bitwise OR | ``|`` | |
52 |
| -+------------+-------------------------------------+--------------------------------------------+ |
53 |
| -| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` | |
54 |
| -+------------+-------------------------------------+--------------------------------------------+ |
55 |
| -| *11* | Equality operators | ``==``, ``!=`` | |
56 |
| -+------------+-------------------------------------+--------------------------------------------+ |
57 |
| -| *12* | Logical AND | ``&&`` | |
58 |
| -+------------+-------------------------------------+--------------------------------------------+ |
59 |
| -| *13* | Logical OR | ``||`` | |
60 |
| -+------------+-------------------------------------+--------------------------------------------+ |
61 |
| -| *14* | Ternary operator | ``<conditional> ? <if-true> : <if-false>`` | |
62 |
| -+ +-------------------------------------+--------------------------------------------+ |
63 |
| -| | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, | |
64 |
| -| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, | |
65 |
| -| | | ``%=`` | |
66 |
| -+------------+-------------------------------------+--------------------------------------------+ |
67 |
| -| *15* | Comma operator | ``,`` | |
68 |
| -+------------+-------------------------------------+--------------------------------------------+ |
| 10 | +:ref:`order` |
69 | 11 |
|
70 | 12 | .. index:: assert, block, coinbase, difficulty, number, block;number, timestamp, block;timestamp, msg, data, gas, sender, value, gas price, origin, revert, require, keccak256, ripemd160, sha256, ecrecover, addmod, mulmod, cryptography, this, super, selfdestruct, balance, codehash, send
|
71 | 13 |
|
|
0 commit comments