mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix incorrect directives
This commit is contained in:
parent
0db67b8895
commit
cb5fc23014
@ -146,13 +146,13 @@ Complications for Arrays and Structs
|
|||||||
The semantics of assignment are a bit more complicated for non-value types like arrays and structs.
|
The semantics of assignment are a bit more complicated for non-value types like arrays and structs.
|
||||||
Assigning *to* a state variable always creates an independent copy. On the other hand, assigning to a local variable creates an independent copy only for elementary types, i.e. static types that fit into 32 bytes. If structs or arrays (including ``bytes`` and ``string``) are assigned from a state variable to a local variable, the local variable holds a reference to the original state variable. A second assignment to the local variable does not modify the state but only changes the reference. Assignments to members (or elements) of the local variable *do* change the state.
|
Assigning *to* a state variable always creates an independent copy. On the other hand, assigning to a local variable creates an independent copy only for elementary types, i.e. static types that fit into 32 bytes. If structs or arrays (including ``bytes`` and ``string``) are assigned from a state variable to a local variable, the local variable holds a reference to the original state variable. A second assignment to the local variable does not modify the state but only changes the reference. Assignments to members (or elements) of the local variable *do* change the state.
|
||||||
|
|
||||||
.. index:: ! exception, ! throw
|
.. index:: ! scoping, declarations, default value
|
||||||
|
|
||||||
|
.. _default-value:
|
||||||
|
|
||||||
Scoping and Declarations
|
Scoping and Declarations
|
||||||
========================
|
========================
|
||||||
|
|
||||||
.. index:: ! scoping, ! declarations, ! default-value
|
|
||||||
|
|
||||||
In Solidity, a variable which is declared is automatically assigned its default value. It will be assigned on contract
|
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.
|
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.
|
This is because the EVM must run deterministically so it would be inappropriate to initialize any variables to random garbage values.
|
||||||
@ -213,6 +213,8 @@ As a result, the following code is legal, despite being poorly written::
|
|||||||
return bar;// returns 5
|
return bar;// returns 5
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.. index:: ! exception, ! throw
|
||||||
|
|
||||||
Exceptions
|
Exceptions
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user