mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Add version pragma to docs examples
This commit is contained in:
parent
9a5aac599e
commit
b2fcd59ee6
@ -182,6 +182,8 @@ Given the contract:
|
||||
|
||||
::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
|
||||
contract Foo {
|
||||
function bar(bytes3[2] xy) {}
|
||||
function baz(uint32 x, bool y) returns (bool r) { r = x > 32 || y; }
|
||||
|
@ -679,6 +679,8 @@ Example:
|
||||
We will follow an example compilation from Solidity to desugared assembly.
|
||||
We consider the runtime bytecode of the following Solidity program::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
|
||||
contract C {
|
||||
function f(uint x) returns (uint y) {
|
||||
y = 1;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -48,6 +48,8 @@ non-elementary type, the positions are found by adding an offset of ``keccak256(
|
||||
|
||||
So for the following contract snippet::
|
||||
|
||||
pragma solidity ^0.4.0;
|
||||
|
||||
contract C {
|
||||
struct s { uint a; uint b; }
|
||||
uint x;
|
||||
|
Loading…
Reference in New Issue
Block a user