aboutsummaryrefslogtreecommitdiffstats
path: root/docs/control-structures.rst
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-11-22 12:59:28 +0800
committerGitHub <noreply@github.com>2017-11-22 12:59:28 +0800
commitbe34b574bf386faf414001c7cb11063c6fe7b6f6 (patch)
tree25f310690066730ba0da1ee2f63318b520f7d06f /docs/control-structures.rst
parentb7fb1bc0a6e7311bf09118c228ba8d93dc944328 (diff)
parent744dea60a40e7e5cb25814c3f6f6eb01dc767698 (diff)
downloaddexon-solidity-be34b574bf386faf414001c7cb11063c6fe7b6f6.tar
dexon-solidity-be34b574bf386faf414001c7cb11063c6fe7b6f6.tar.gz
dexon-solidity-be34b574bf386faf414001c7cb11063c6fe7b6f6.tar.bz2
dexon-solidity-be34b574bf386faf414001c7cb11063c6fe7b6f6.tar.lz
dexon-solidity-be34b574bf386faf414001c7cb11063c6fe7b6f6.tar.xz
dexon-solidity-be34b574bf386faf414001c7cb11063c6fe7b6f6.tar.zst
dexon-solidity-be34b574bf386faf414001c7cb11063c6fe7b6f6.zip
Merge pull request #3152 from ethereum/docs-tests
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.rst22
1 files changed, 13 insertions, 9 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index 0497365b..bcb597cf 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -194,7 +194,7 @@ Omitted Function Parameter Names
--------------------------------
The names of unused parameters (especially return parameters) can be omitted.
-Those names will still be present on the stack, but they are inaccessible.
+Those parameters will still be present on the stack, but they are inaccessible.
::
@@ -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