mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests, Docs and Changelog
This commit is contained in:
@@ -488,12 +488,11 @@ shown in the following example:
|
||||
|
||||
function newCampaign(address payable beneficiary, uint goal) public returns (uint campaignID) {
|
||||
campaignID = numCampaigns++; // campaignID is return variable
|
||||
// Creates new struct in memory and copies it to storage.
|
||||
// We leave out the mapping type, because it is not valid in memory.
|
||||
// If structs are copied (even from storage to storage),
|
||||
// types that are not valid outside of storage (ex. mappings and array of mappings)
|
||||
// are always omitted, because they cannot be enumerated.
|
||||
campaigns[campaignID] = Campaign(beneficiary, goal, 0, 0);
|
||||
// We cannot use "campaigns[campaignID] = Campaign(beneficiary, goal, 0, 0)"
|
||||
// because the RHS creates a memory-struct "Campaign" that contains a mapping.
|
||||
Campaign storage c = campaigns[campaignID];
|
||||
c.beneficiary = beneficiary;
|
||||
c.fundingGoal = goal;
|
||||
}
|
||||
|
||||
function contribute(uint campaignID) public payable {
|
||||
|
||||
Reference in New Issue
Block a user