aboutsummaryrefslogtreecommitdiffstats
path: root/docs/types.rst
diff options
context:
space:
mode:
authorWilliam Entriken <github.com@phor.net>2018-08-28 11:43:10 +0800
committerchriseth <chris@ethereum.org>2018-09-21 02:57:38 +0800
commitea6bb340d484fe67a48d0ee4709fa00d501fc0f8 (patch)
tree686ab0d6c51bfc0550c2f31182306e7026d169a6 /docs/types.rst
parentc43bbd1a68f6291886a4df07b1fc205f2d38c4df (diff)
downloaddexon-solidity-ea6bb340d484fe67a48d0ee4709fa00d501fc0f8.tar.gz
dexon-solidity-ea6bb340d484fe67a48d0ee4709fa00d501fc0f8.tar.zst
dexon-solidity-ea6bb340d484fe67a48d0ee4709fa00d501fc0f8.zip
Document array length changing behaviors, fixes #4802
Diffstat (limited to 'docs/types.rst')
-rw-r--r--docs/types.rst7
1 files changed, 3 insertions, 4 deletions
diff --git a/docs/types.rst b/docs/types.rst
index c5ce4c31..49a0506a 100644
--- a/docs/types.rst
+++ b/docs/types.rst
@@ -830,13 +830,12 @@ Members
^^^^^^^
**length**:
- Arrays have a ``length`` member to hold their number of elements.
- Dynamic arrays can be resized in storage (not in memory) by changing the
- ``.length`` member. This does not happen automatically when attempting to access elements outside the current length. The size of memory arrays is fixed (but dynamic, i.e. it can depend on runtime parameters) once they are created.
+ Arrays have a ``length`` member to read their number of elements.
+ Dynamically-sized arrays (only available for storage) have a read-write ``length`` member to resize the array. Increasing the length adds uninitialized elements to the array, this has *O(1)* complexity. Reducing the length performs :ref:``delete`` on each removed element and has *O(n)* complexity where *n* is the number of elements being deleted. Please note that calling ``length--`` on an empty array will set the length of the array to 2^256-1 due to ``uint256`` underflow wrapping.
**push**:
Dynamic storage arrays and ``bytes`` (not ``string``) have a member function called ``push`` that can be used to append an element at the end of the array. The function returns the new length.
**pop**:
- Dynamic storage arrays and ``bytes`` (not ``string``) have a member function called ``pop`` that can be used to remove an element from the end of the array.
+ Dynamic storage arrays and ``bytes`` (not ``string``) have a member function called ``pop`` that can be used to remove an element from the end of the array. This will also implicitly call :ref:``delete`` on the removed element.
.. warning::
It is not yet possible to use arrays of arrays in external functions.