aboutsummaryrefslogtreecommitdiffstats
path: root/docs/control-structures.rst
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-07-11 05:58:23 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-07-13 23:10:37 +0800
commitb2fcd59ee6941de4a392b89295c734385d6019e3 (patch)
tree7f40372a2d95ec35ed707bdd63958bb9e68b97ee /docs/control-structures.rst
parent9a5aac599e0003009fd0ba1794c6a02d97b3d026 (diff)
downloaddexon-solidity-b2fcd59ee6941de4a392b89295c734385d6019e3.tar.gz
dexon-solidity-b2fcd59ee6941de4a392b89295c734385d6019e3.tar.zst
dexon-solidity-b2fcd59ee6941de4a392b89295c734385d6019e3.zip
Add version pragma to docs examples
Diffstat (limited to 'docs/control-structures.rst')
-rw-r--r--docs/control-structures.rst10
1 files changed, 10 insertions, 0 deletions
diff --git a/docs/control-structures.rst b/docs/control-structures.rst
index 03787c20..c7185e22 100644
--- a/docs/control-structures.rst
+++ b/docs/control-structures.rst
@@ -20,6 +20,8 @@ For example, suppose we want our contract to
accept one kind of external calls with two integers, we would write
something like::
+ pragma solidity ^0.4.0;
+
contract Simple {
function taker(uint _a, uint _b) {
// do something with _a and _b.
@@ -34,6 +36,8 @@ The output parameters can be declared with the same syntax after the
the sum and the product of the two given integers, then we would
write::
+ pragma solidity ^0.4.0;
+
contract Simple {
function arithmetics(uint _a, uint _b) returns (uint o_sum, uint o_product) {
o_sum = _a + _b;
@@ -91,6 +95,8 @@ Internal Function Calls
Functions of the current contract can be called directly ("internally"), also recursively, as seen in
this nonsensical example::
+ pragma solidity ^0.4.0;
+
contract C {
function g(uint a) returns (uint ret) { return f(); }
function f() returns (uint ret) { return g(7) + f(); }
@@ -116,6 +122,8 @@ all function arguments have to be copied to memory.
When calling functions of other contracts, the amount of Wei sent with the call and
the gas can be specified with special options ``.value()`` and ``.gas()``, respectively::
+ pragma solidity ^0.4.0;
+
contract InfoFeed {
function info() payable returns (uint ret) { return 42; }
}
@@ -261,6 +269,8 @@ Destructuring Assignments and Returning Multiple Values
Solidity internally allows tuple types, i.e. a list of objects of potentially different types whose size is a constant at compile-time. Those tuples can be used to return multiple values at the same time and also assign them to multiple variables (or LValues in general) at the same time::
+ pragma solidity ^0.4.0;
+
contract C {
uint[] data;