diff options
author | chriseth <chris@ethereum.org> | 2018-02-19 23:58:56 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2018-02-27 07:02:39 +0800 |
commit | 098033c94a6bbedaee60b19f096dfee5bf2b4550 (patch) | |
tree | 8f6b47c266a4514db37447a1fec8082af1952d8d | |
parent | b62d43912badc10f07b693a79834dcd3249f082a (diff) | |
download | dexon-solidity-098033c94a6bbedaee60b19f096dfee5bf2b4550.tar.gz dexon-solidity-098033c94a6bbedaee60b19f096dfee5bf2b4550.tar.zst dexon-solidity-098033c94a6bbedaee60b19f096dfee5bf2b4550.zip |
Fix name shadowing in ballot example contract.
-rw-r--r-- | docs/solidity-by-example.rst | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index e5b44c98..57556fa5 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -94,7 +94,11 @@ of votes. // called incorrectly. But watch out, this // will currently also consume all provided gas // (this is planned to change in the future). - require((msg.sender == chairperson) && !voters[voter].voted && (voters[voter].weight == 0)); + require( + (msg.sender == chairperson) && + !voters[voter].voted && + (voters[voter].weight == 0) + ); voters[voter].weight = 1; } @@ -126,15 +130,15 @@ of votes. // modifies `voters[msg.sender].voted` sender.voted = true; sender.delegate = to; - Voter storage delegate = voters[to]; - if (delegate.voted) { + Voter storage delegate_ = voters[to]; + if (delegate_.voted) { // If the delegate already voted, // directly add to the number of votes - proposals[delegate.vote].voteCount += sender.weight; + proposals[delegate_.vote].voteCount += sender.weight; } else { // If the delegate did not vote yet, // add to her weight. - delegate.weight += sender.weight; + delegate_.weight += sender.weight; } } @@ -155,13 +159,13 @@ of votes. /// @dev Computes the winning proposal taking all /// previous votes into account. function winningProposal() public view - returns (uint winningProposal) + returns (uint winningProposal_) { uint winningVoteCount = 0; for (uint p = 0; p < proposals.length; p++) { if (proposals[p].voteCount > winningVoteCount) { winningVoteCount = proposals[p].voteCount; - winningProposal = p; + winningProposal_ = p; } } } @@ -170,12 +174,13 @@ of votes. // of the winner contained in the proposals array and then // returns the name of the winner function winnerName() public view - returns (bytes32 winnerName) + returns (bytes32 winnerName_) { - winnerName = proposals[winningProposal()].name; + winnerName_ = proposals[winningProposal()].name; } } + Possible Improvements ===================== |