diff options
author | Oleksii Matiiasevych <lastperson@gmail.com> | 2018-03-01 23:54:04 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-03-01 23:54:04 +0800 |
commit | a0d006015e253b88626d2489e8cd8b5b537f5079 (patch) | |
tree | 58685295d9313ffde6952b78929ecc1c8e9d7d03 /docs/miscellaneous.rst | |
parent | 2c82f748bb91a7c44ae112f5f4fc22bb63d7f861 (diff) | |
download | dexon-solidity-a0d006015e253b88626d2489e8cd8b5b537f5079.tar dexon-solidity-a0d006015e253b88626d2489e8cd8b5b537f5079.tar.gz dexon-solidity-a0d006015e253b88626d2489e8cd8b5b537f5079.tar.bz2 dexon-solidity-a0d006015e253b88626d2489e8cd8b5b537f5079.tar.lz dexon-solidity-a0d006015e253b88626d2489e8cd8b5b537f5079.tar.xz dexon-solidity-a0d006015e253b88626d2489e8cd8b5b537f5079.tar.zst dexon-solidity-a0d006015e253b88626d2489e8cd8b5b537f5079.zip |
Update Tips and Tricks on structs initialization. (#3626)
* Update Tips and Tricks on structs initialization.
Diffstat (limited to 'docs/miscellaneous.rst')
-rw-r--r-- | docs/miscellaneous.rst | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/docs/miscellaneous.rst b/docs/miscellaneous.rst index b5d605ac..70ed6201 100644 --- a/docs/miscellaneous.rst +++ b/docs/miscellaneous.rst @@ -230,7 +230,10 @@ Tips and Tricks * Make your state variables public - the compiler will create :ref:`getters <visibility-and-getters>` for you automatically. * If you end up checking conditions on input or state a lot at the beginning of your functions, try using :ref:`modifiers`. * If your contract has a function called ``send`` but you want to use the built-in send-function, use ``address(contractVariable).send(amount)``. -* Initialise storage structs with a single assignment: ``x = MyStruct({a: 1, b: 2});`` +* Initialize storage structs with a single assignment: ``x = MyStruct({a: 1, b: 2});`` + +.. note:: + If the storage struct has tightly packed properties, initialize it with separate assignments: ``x.a = 1; x.b = 2;``. In this way it will be easier for the optimizer to update storage in one go, thus making assignment cheaper. ********** Cheatsheet |