I am a bit confused about the uint "id" in the start function.
I understand that the uint "nextCampaignId" is a global variable, and so changes made to it will be saved in storage; which means that with each new campaign created, "nextCampaignId" will be incremented, and so cannot be used to determine ID numbers of previously created campaigns. Hence, we need to assign its value to a new uint "id" within the function.
However, I thought integers declared within functions do not get saved in storage. Wouldn't this ID number be lost once the function is terminated? Does the function simply return the ID (to the UI) and then forgets it? But then how can we retrieve specific campaign data later?
uint nextCampaignId;
mapping(uint256 => CampaignData) campaigns;
// Start a new campaign.
function start(address recipient, uint256 goal, uint256 deadline) returns
(uint id) {
var campaign = campaigns[nextCampaignId];
campaign.recipient = recipient;
campaign.goal = goal;
campaign.deadline = deadline;
nextCampaignId ++;
id = nextCampaignId;
}