aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorChris Ward <chriswhward@gmail.com>2018-08-22 20:28:43 +0800
committerChris Ward <chriswhward@gmail.com>2018-08-22 20:28:43 +0800
commit1475cde2889d0187c596304cbfa08a63e0e31f61 (patch)
treefd5554389182abd951f3d5f06785de4caf238602 /docs
parent410d288dfc2e08c42df58c7e01ad5c332ce92727 (diff)
downloaddexon-solidity-1475cde2889d0187c596304cbfa08a63e0e31f61.tar
dexon-solidity-1475cde2889d0187c596304cbfa08a63e0e31f61.tar.gz
dexon-solidity-1475cde2889d0187c596304cbfa08a63e0e31f61.tar.bz2
dexon-solidity-1475cde2889d0187c596304cbfa08a63e0e31f61.tar.lz
dexon-solidity-1475cde2889d0187c596304cbfa08a63e0e31f61.tar.xz
dexon-solidity-1475cde2889d0187c596304cbfa08a63e0e31f61.tar.zst
dexon-solidity-1475cde2889d0187c596304cbfa08a63e0e31f61.zip
Update Infofeed example code and explanation
Diffstat (limited to 'docs')
-rw-r--r--docs/control-structures.rst19
1 files changed, 7 insertions, 12 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index d0e58908..3d056180 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -135,23 +135,18 @@ the gas can be specified with special options ``.value()`` and ``.gas()``, respe
contract Consumer {
InfoFeed feed;
- function setFeed(address addr) public { feed = InfoFeed(addr); }
+ function setFeed(InfoFeed addr) public { feed = addr; }
function callFeed() public { feed.info.value(10).gas(800)(); }
}
-The modifier ``payable`` has to be used for ``info``, because otherwise, the `.value()`
-option would not be available.
+You need to use the modifier ``payable`` with the ``info`` function because
+otherwise, the ``.value()`` option would not be available.
-Note that the expression ``InfoFeed(addr)`` performs an explicit type conversion stating
-that "we know that the type of the contract at the given address is ``InfoFeed``" and
-this does not execute a constructor. Explicit type conversions have to be
-handled with extreme caution. Never call a function on a contract where you
-are not sure about its type.
+You can also use ``function setFeed(InfoFeed _feed) { feed = _feed; }``
+directly.
-We could also have used ``function setFeed(InfoFeed _feed) { feed = _feed; }`` directly.
-Be careful about the fact that ``feed.info.value(10).gas(800)``
-only (locally) sets the value and amount of gas sent with the function call and only the
-parentheses at the end perform the actual call.
+.. warning::
+ Be careful that ``feed.info.value(10).gas(800)`` only locally sets the ``value`` and amount of ``gas`` sent with the function call, and the parentheses at the end perform the actual call.
Function calls cause exceptions if the called contract does not exist (in the
sense that the account does not contain code) or if the called contract itself