Merge pull request #11636 from ethereum/docs-clarify-struct-members-omitted-by-getters

[Docs] Clarify that non-byte array struct members are omitted by getters
This commit is contained in:
chriseth 2021-07-08 15:39:31 +02:00 committed by GitHub
commit c3fa520c75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,16 +188,24 @@ The next example is more complex:
uint a;
bytes3 b;
mapping (uint => uint) map;
uint[3] c;
uint[] d;
bytes e;
}
mapping (uint => mapping(bool => Data[])) public data;
}
It generates a function of the following form. The mapping in the struct is omitted
because there is no good way to provide the key for the mapping:
It generates a function of the following form. The mapping and arrays (with the
exception of byte arrays) in the struct are omitted because there is no good way
to select individual struct members or provide a key for the mapping:
.. code-block:: solidity
function data(uint arg1, bool arg2, uint arg3) public returns (uint a, bytes3 b) {
function data(uint arg1, bool arg2, uint arg3)
public
returns (uint a, bytes3 b, bytes memory e)
{
a = data[arg1][arg2][arg3].a;
b = data[arg1][arg2][arg3].b;
e = data[arg1][arg2][arg3].e;
}