diff options
author | Denton Liu <liu.denton+github@gmail.com> | 2016-05-18 23:05:28 +0800 |
---|---|---|
committer | Denton Liu <liu.denton+github@gmail.com> | 2016-05-18 23:35:32 +0800 |
commit | 7c22a387f34d5cbc92b6b6ed78c281a480ba7739 (patch) | |
tree | 8300e1a97cc6537ff463ef705a5b28b313cfb6a0 /docs/control-structures.rst | |
parent | ff26ea6c08a400192c5a5fff581a7ce649f717bd (diff) | |
download | dexon-solidity-7c22a387f34d5cbc92b6b6ed78c281a480ba7739.tar dexon-solidity-7c22a387f34d5cbc92b6b6ed78c281a480ba7739.tar.gz dexon-solidity-7c22a387f34d5cbc92b6b6ed78c281a480ba7739.tar.bz2 dexon-solidity-7c22a387f34d5cbc92b6b6ed78c281a480ba7739.tar.lz dexon-solidity-7c22a387f34d5cbc92b6b6ed78c281a480ba7739.tar.xz dexon-solidity-7c22a387f34d5cbc92b6b6ed78c281a480ba7739.tar.zst dexon-solidity-7c22a387f34d5cbc92b6b6ed78c281a480ba7739.zip |
Changed whitespace formatting
Diffstat (limited to 'docs/control-structures.rst')
-rw-r--r-- | docs/control-structures.rst | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 0a233763..8d1788d3 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -55,6 +55,8 @@ of other contracts, the amount of Wei sent with the call and the gas can be spec contract InfoFeed { function info() returns (uint ret) { return 42; } } + + contract Consumer { InfoFeed feed; function setFeed(address addr) { feed = InfoFeed(addr); } @@ -77,10 +79,12 @@ of unused parameters (especially return parameters) can be omitted. contract c { function f(uint key, uint value) { ... } + function g() { // named arguments f({value: 2, key: 3}); } + // omitted parameters function func(uint k, uint) returns(uint) { return k; @@ -212,7 +216,7 @@ In the following example, we show how `throw` can be used to easily revert an Et contract Sharer { function sendHalf(address addr) returns (uint balance) { - if (!addr.send(msg.value/2)) + if (!addr.send(msg.value / 2)) throw; // also reverts the transfer to Sharer return this.balance; } @@ -290,6 +294,7 @@ you really know what you are doing. for (uint i = 0; i < _data.length; ++i) o_sum += _data[i]; } + // We know that we only access the array in bounds, so we can avoid the check. // 0x20 needs to be added to an array because the first slot contains the // array length. |