aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorDenton Liu <liu.denton+github@gmail.com>2016-07-05 23:44:39 +0800
committerDenton Liu <liu.denton+github@gmail.com>2016-07-05 23:44:39 +0800
commit14f57568dcee8b2fae60f94d4b77986708c06667 (patch)
tree611b38ba8b9de75ed215855ff6f3cfb8995439fd /docs
parentd4d7d9854a16ae47dba9537029e59191f742fd40 (diff)
downloaddexon-solidity-14f57568dcee8b2fae60f94d4b77986708c06667.tar.gz
dexon-solidity-14f57568dcee8b2fae60f94d4b77986708c06667.tar.zst
dexon-solidity-14f57568dcee8b2fae60f94d4b77986708c06667.zip
Apply fixes
Diffstat (limited to 'docs')
-rw-r--r--docs/control-structures.rst9
1 files changed, 4 insertions, 5 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index 96768919..8893a8d9 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -153,13 +153,12 @@ Assigning *to* a state variable always creates an independent copy. On the other
Scoping and Declarations
========================
-In Solidity, a variable which is declared is automatically assigned its default value. It will be assigned on contract
-initialization if it is a contract-level variable or at the beginning of a function call if it is a local variable.
-This is because the EVM must run deterministically so it would be inappropriate to initialize any variables to random garbage values.
+A variable which is declared will have an initial default value whose byte-representation is all zeros.
+This is because the EVM must run without undefined behaviour so it would be inappropriate to initialize any variables to random garbage values.
The "default values" of variables are the typical "zero-state" of whatever the type is. For example, the default value for a ``bool``
-is ``false``. The default value for the ``uint`` or ``int`` types is ``0``. For statically-sized arrays and ``bytes``, each individual
+is ``false``. The default value for the ``uint`` or ``int`` types is ``0``. For statically-sized arrays and ``bytes1`` to ``bytes32``, each individual
element will be initialized to the default value corresponding to its type. Finally, for dynamically-sized arrays, ``bytes``
-and ``strings``, the default value is a zero-length member of its respective type.
+and ``string``, the default value is an empty array or a zero-length member of its respective type.
A variable declared anywhere within a function will be in scope for the *entire function*, regardless of where it is declared.
This happens because Solidity inherits its scoping rules from JavaScript.