mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
commit
b75b0a3739
@ -199,6 +199,7 @@ latex_elements = {
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'solidity.tex', 'Solidity Documentation', 'Ethereum', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -547,6 +547,13 @@ Can a regular (i.e. non-contract) ethereum account be closed permanently like a
|
||||
No. Non-contract accounts "exist" as long as the private key is known by
|
||||
someone or can be generated in some way.
|
||||
|
||||
What is the difference between `bytes` and `byte[]`?
|
||||
====================================================
|
||||
|
||||
`bytes` is usually more efficient: When used as arguments to functions (i.e. in
|
||||
CALLDATA) or in memory, every single element of a `byte[]` is padded to 32
|
||||
bytes which wastes 31 bytes per element.
|
||||
|
||||
******************
|
||||
Advanced Questions
|
||||
******************
|
||||
|
@ -513,7 +513,7 @@ No::
|
||||
x |= y&&z;
|
||||
|
||||
* Operators with a higher priority than others can exclude surrounding
|
||||
whitespace in order to denote precidence. This is meant to allow for
|
||||
whitespace in order to denote precedence. This is meant to allow for
|
||||
improved readability for complex statement. You should always use the same
|
||||
amount of whitespace on either side of an operator:
|
||||
|
||||
|
@ -119,6 +119,10 @@ Dynamically-sized byte array
|
||||
`string`:
|
||||
Dynamically-sized UTF8-encoded string, see :ref:`arrays`. Not a value-type!
|
||||
|
||||
As a rule of thumb, use `bytes` for arbitrary-length raw byte data and `string`
|
||||
for arbitrary-length string (utf-8) data. If you can limit the length to a certain
|
||||
number of bytes, always use one of `bytes1` to `bytes32` because they are much cheaper.
|
||||
|
||||
.. index:: literal, literal;integer
|
||||
|
||||
Integer Literals
|
||||
@ -261,6 +265,8 @@ Variables of type `bytes` and `string` are special arrays. A `bytes` is similar
|
||||
but it is packed tightly in calldata. `string` is equal to `bytes` but does not allow
|
||||
length or index access (for now).
|
||||
|
||||
So `bytes` should always be preferred over `byte[]` because it is cheaper.
|
||||
|
||||
.. note::
|
||||
If you want to access the byte-representation of a string `s`, use
|
||||
`bytes(s).length` / `bytes(s)[7] = 'x';`. Keep in mind
|
||||
|
Loading…
Reference in New Issue
Block a user