mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Allocating arrays.
This commit is contained in:
parent
11d67369bd
commit
a762694f1d
@ -291,6 +291,23 @@ So `bytes` should always be preferred over `byte[]` because it is cheaper.
|
|||||||
that you are accessing the low-level bytes of the utf-8 representation,
|
that you are accessing the low-level bytes of the utf-8 representation,
|
||||||
and not the individual characters!
|
and not the individual characters!
|
||||||
|
|
||||||
|
.. index:: ! array;allocating, new
|
||||||
|
|
||||||
|
Allocating Memory Arrays
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
Creating arrays with variable length in memory can be done using the `new` keyword:
|
||||||
|
|
||||||
|
::
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f(uint len) {
|
||||||
|
uint[] a = new uint[](7);
|
||||||
|
bytes b = new bytes(len);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.. index:: ! array;length, length, push, !array;push
|
.. index:: ! array;length, length, push, !array;push
|
||||||
|
|
||||||
Members
|
Members
|
||||||
|
Loading…
Reference in New Issue
Block a user