mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #13916 from NicoAcosta/mapping-style
Fix mapping style in docs
This commit is contained in:
commit
78608e8d17
@ -34,7 +34,7 @@ you receive the funds of the person who is now the richest.
|
||||
address public richest;
|
||||
uint public mostSent;
|
||||
|
||||
mapping (address => uint) pendingWithdrawals;
|
||||
mapping(address => uint) pendingWithdrawals;
|
||||
|
||||
/// The amount of Ether sent was not higher than
|
||||
/// the currently highest amount.
|
||||
|
@ -61,7 +61,7 @@ if they are marked ``virtual``. For details, please see
|
||||
}
|
||||
|
||||
contract Register is priced, destructible {
|
||||
mapping (address => bool) registeredAddresses;
|
||||
mapping(address => bool) registeredAddresses;
|
||||
uint price;
|
||||
|
||||
constructor(uint initialPrice) { price = initialPrice; }
|
||||
|
@ -200,12 +200,12 @@ The next example is more complex:
|
||||
struct Data {
|
||||
uint a;
|
||||
bytes3 b;
|
||||
mapping (uint => uint) map;
|
||||
mapping(uint => uint) map;
|
||||
uint[3] c;
|
||||
uint[] d;
|
||||
bytes e;
|
||||
}
|
||||
mapping (uint => mapping(bool => Data[])) public data;
|
||||
mapping(uint => mapping(bool => Data[])) public data;
|
||||
}
|
||||
|
||||
It generates a function of the following form. The mapping and arrays (with the
|
||||
|
@ -34,7 +34,7 @@ and the sum of all balances is an invariant across the lifetime of the contract.
|
||||
contract Token {
|
||||
mapping(address => uint256) balances;
|
||||
using Balances for *;
|
||||
mapping(address => mapping (address => uint256)) allowed;
|
||||
mapping(address => mapping(address => uint256)) allowed;
|
||||
|
||||
event Transfer(address from, address to, uint amount);
|
||||
event Approval(address owner, address spender, uint amount);
|
||||
|
@ -232,7 +232,7 @@ value and reference types, types that are encoded packed, and nested types.
|
||||
uint y;
|
||||
S s;
|
||||
address addr;
|
||||
mapping (uint => mapping (address => bool)) map;
|
||||
mapping(uint => mapping(address => bool)) map;
|
||||
uint[] array;
|
||||
string s1;
|
||||
bytes b1;
|
||||
|
@ -91,7 +91,7 @@ registering with a username and password, all you need is an Ethereum keypair.
|
||||
// The keyword "public" makes variables
|
||||
// accessible from other contracts
|
||||
address public minter;
|
||||
mapping (address => uint) public balances;
|
||||
mapping(address => uint) public balances;
|
||||
|
||||
// Events allow clients to react to specific
|
||||
// contract changes you declare
|
||||
@ -151,7 +151,7 @@ You do not need to do this, the compiler figures it out for you.
|
||||
|
||||
.. index:: mapping
|
||||
|
||||
The next line, ``mapping (address => uint) public balances;`` also
|
||||
The next line, ``mapping(address => uint) public balances;`` also
|
||||
creates a public state variable, but it is a more complex datatype.
|
||||
The :ref:`mapping <mapping-types>` type maps addresses to :ref:`unsigned integers <integers>`.
|
||||
|
||||
|
@ -336,7 +336,7 @@ field of a ``struct`` that is the base type of a dynamic storage array. The
|
||||
pragma solidity >=0.6.0 <0.9.0;
|
||||
|
||||
contract Map {
|
||||
mapping (uint => uint)[] array;
|
||||
mapping(uint => uint)[] array;
|
||||
|
||||
function allocate(uint newMaps) public {
|
||||
for (uint i = 0; i < newMaps; i++)
|
||||
|
@ -95,8 +95,8 @@ The example below uses ``_allowances`` to record the amount someone else is allo
|
||||
|
||||
contract MappingExample {
|
||||
|
||||
mapping (address => uint256) private _balances;
|
||||
mapping (address => mapping (address => uint256)) private _allowances;
|
||||
mapping(address => uint256) private _balances;
|
||||
mapping(address => mapping(address => uint256)) private _allowances;
|
||||
|
||||
event Transfer(address indexed from, address indexed to, uint256 value);
|
||||
event Approval(address indexed owner, address indexed spender, uint256 value);
|
||||
|
@ -686,11 +686,11 @@ shown in the following example:
|
||||
uint fundingGoal;
|
||||
uint numFunders;
|
||||
uint amount;
|
||||
mapping (uint => Funder) funders;
|
||||
mapping(uint => Funder) funders;
|
||||
}
|
||||
|
||||
uint numCampaigns;
|
||||
mapping (uint => Campaign) campaigns;
|
||||
mapping(uint => Campaign) campaigns;
|
||||
|
||||
function newCampaign(address payable beneficiary, uint goal) public returns (uint campaignID) {
|
||||
campaignID = numCampaigns++; // campaignID is return variable
|
||||
|
Loading…
Reference in New Issue
Block a user