diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-10-29 21:28:42 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-11-22 12:08:35 +0800 |
commit | 23379e10614cccf9126fca09781a1d2dcdfede90 (patch) | |
tree | 089c555949ed76eea06e611e8a9eebc638e248e9 /docs/control-structures.rst | |
parent | b7fb1bc0a6e7311bf09118c228ba8d93dc944328 (diff) | |
download | dexon-solidity-23379e10614cccf9126fca09781a1d2dcdfede90.tar.gz dexon-solidity-23379e10614cccf9126fca09781a1d2dcdfede90.tar.zst dexon-solidity-23379e10614cccf9126fca09781a1d2dcdfede90.zip |
Ensure each code snippet in the docs can be extracted for tests
Diffstat (limited to 'docs/control-structures.rst')
-rw-r--r-- | docs/control-structures.rst | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst index 0497365b..371c5b92 100644 --- a/docs/control-structures.rst +++ b/docs/control-structures.rst @@ -363,15 +363,19 @@ As a result, the following code is illegal and cause the compiler to throw an er In addition to this, if a variable is declared, it will be initialized at the beginning of the function to its default value. As a result, the following code is legal, despite being poorly written:: - function foo() returns (uint) { - // baz is implicitly initialized as 0 - uint bar = 5; - if (true) { - bar += baz; - } else { - uint baz = 10;// never executes + pragma solidity ^0.4.0; + + contract C { + function foo() returns (uint) { + // baz is implicitly initialized as 0 + uint bar = 5; + if (true) { + bar += baz; + } else { + uint baz = 10;// never executes + } + return bar;// returns 5 } - return bar;// returns 5 } .. index:: ! exception, ! throw, ! assert, ! require, ! revert |