diff options
author | chriseth <chris@ethereum.org> | 2018-11-26 21:51:38 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-11-26 21:51:38 +0800 |
commit | 7cc6738df3d64f9597adc77a84dbfab3888728a1 (patch) | |
tree | acf50997c3994acf9432f291a3c65e318c4476c3 /docs/frequently-asked-questions.rst | |
parent | d00082f12f60ad4a76123e0905e5e3c76c1d2643 (diff) | |
parent | f57ef36c0e5fdefcb0893c51d466f6b4bb674797 (diff) | |
download | dexon-solidity-7cc6738df3d64f9597adc77a84dbfab3888728a1.tar.gz dexon-solidity-7cc6738df3d64f9597adc77a84dbfab3888728a1.tar.zst dexon-solidity-7cc6738df3d64f9597adc77a84dbfab3888728a1.zip |
Merge pull request #5438 from ethereum/docs-faq-types-undefined
DOCS: Move undefined FAQ item
Diffstat (limited to 'docs/frequently-asked-questions.rst')
-rw-r--r-- | docs/frequently-asked-questions.rst | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst index b6e5fe78..9cc08822 100644 --- a/docs/frequently-asked-questions.rst +++ b/docs/frequently-asked-questions.rst @@ -143,44 +143,6 @@ arguments for you. See `ping.sol <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/45_ping.sol>`_ and `pong.sol <https://github.com/fivedogit/solidity-baby-steps/blob/master/contracts/45_pong.sol>`_. -When returning a value of say ``uint`` type, is it possible to return an ``undefined`` or "null"-like value? -============================================================================================================ - -This is not possible, because all types use up the full value range. - -You have the option to ``throw`` on error, which will also revert the whole -transaction, which might be a good idea if you ran into an unexpected -situation. - -If you do not want to throw, you can return a pair:: - - pragma solidity >0.4.23 <0.6.0; - - contract C { - uint[] counters; - - function getCounter(uint index) - public - view - returns (uint counter, bool error) { - if (index >= counters.length) - return (0, true); - else - return (counters[index], false); - } - - function checkCounter(uint index) public view { - (uint counter, bool error) = getCounter(index); - if (error) { - // Handle the error - } else { - // Do something with counter. - require(counter > 7, "Invalid counter value"); - } - } - } - - Are comments included with deployed contracts and do they increase deployment gas? ================================================================================== |