mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #13048 from shadyy41/moving-operator-precedence
Move operator precedence from cheatsheet to operators
This commit is contained in:
commit
fdc3c8eede
@ -2,70 +2,12 @@
|
|||||||
Cheatsheet
|
Cheatsheet
|
||||||
**********
|
**********
|
||||||
|
|
||||||
.. index:: precedence
|
.. index:: operator; precedence
|
||||||
|
|
||||||
.. _order:
|
|
||||||
|
|
||||||
Order of Precedence of Operators
|
Order of Precedence of Operators
|
||||||
================================
|
================================
|
||||||
|
|
||||||
The following is the order of precedence for operators, listed in order of evaluation.
|
:ref:`order`
|
||||||
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| Precedence | Description | Operator |
|
|
||||||
+============+=====================================+============================================+
|
|
||||||
| *1* | Postfix increment and decrement | ``++``, ``--`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | New expression | ``new <typename>`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Array subscripting | ``<array>[<index>]`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Member access | ``<object>.<member>`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Function-like call | ``<func>(<args...>)`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Parentheses | ``(<statement>)`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *2* | Prefix increment and decrement | ``++``, ``--`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Unary minus | ``-`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Unary operations | ``delete`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Logical NOT | ``!`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Bitwise NOT | ``~`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *3* | Exponentiation | ``**`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *5* | Addition and subtraction | ``+``, ``-`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *6* | Bitwise shift operators | ``<<``, ``>>`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *7* | Bitwise AND | ``&`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *8* | Bitwise XOR | ``^`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *9* | Bitwise OR | ``|`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *11* | Equality operators | ``==``, ``!=`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *12* | Logical AND | ``&&`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *13* | Logical OR | ``||`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *14* | Ternary operator | ``<conditional> ? <if-true> : <if-false>`` |
|
|
||||||
+ +-------------------------------------+--------------------------------------------+
|
|
||||||
| | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, |
|
|
||||||
| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, |
|
|
||||||
| | | ``%=`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
| *15* | Comma operator | ``,`` |
|
|
||||||
+------------+-------------------------------------+--------------------------------------------+
|
|
||||||
|
|
||||||
.. 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
|
.. 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
|
||||||
|
|
||||||
|
@ -108,3 +108,67 @@ value it referred to previously.
|
|||||||
assert(y.length == 0);
|
assert(y.length == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.. index:: ! operator; precedence
|
||||||
|
.. _order:
|
||||||
|
|
||||||
|
Order of Precedence of Operators
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
The following is the order of precedence for operators, listed in order of evaluation.
|
||||||
|
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| Precedence | Description | Operator |
|
||||||
|
+============+=====================================+============================================+
|
||||||
|
| *1* | Postfix increment and decrement | ``++``, ``--`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | New expression | ``new <typename>`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Array subscripting | ``<array>[<index>]`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Member access | ``<object>.<member>`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Function-like call | ``<func>(<args...>)`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Parentheses | ``(<statement>)`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *2* | Prefix increment and decrement | ``++``, ``--`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Unary minus | ``-`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Unary operations | ``delete`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Logical NOT | ``!`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Bitwise NOT | ``~`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *3* | Exponentiation | ``**`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *4* | Multiplication, division and modulo | ``*``, ``/``, ``%`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *5* | Addition and subtraction | ``+``, ``-`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *6* | Bitwise shift operators | ``<<``, ``>>`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *7* | Bitwise AND | ``&`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *8* | Bitwise XOR | ``^`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *9* | Bitwise OR | ``|`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *10* | Inequality operators | ``<``, ``>``, ``<=``, ``>=`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *11* | Equality operators | ``==``, ``!=`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *12* | Logical AND | ``&&`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *13* | Logical OR | ``||`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *14* | Ternary operator | ``<conditional> ? <if-true> : <if-false>`` |
|
||||||
|
+ +-------------------------------------+--------------------------------------------+
|
||||||
|
| | Assignment operators | ``=``, ``|=``, ``^=``, ``&=``, ``<<=``, |
|
||||||
|
| | | ``>>=``, ``+=``, ``-=``, ``*=``, ``/=``, |
|
||||||
|
| | | ``%=`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
| *15* | Comma operator | ``,`` |
|
||||||
|
+------------+-------------------------------------+--------------------------------------------+
|
||||||
|
Loading…
Reference in New Issue
Block a user