diff options
author | varunagarwal315 <varunagarwal315@gmail.com> | 2016-11-03 20:12:05 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-03 20:12:05 +0800 |
commit | 38e0b0a5faf75e3392fbfdd371b27db728026853 (patch) | |
tree | 3db1e1c5911f65b1f90c885911fa7162ecce5eb6 /docs/solidity-by-example.rst | |
parent | 4c105dba0714564c2a31dac5ded8e994d0625dd1 (diff) | |
download | dexon-solidity-38e0b0a5faf75e3392fbfdd371b27db728026853.tar.gz dexon-solidity-38e0b0a5faf75e3392fbfdd371b27db728026853.tar.zst dexon-solidity-38e0b0a5faf75e3392fbfdd371b27db728026853.zip |
Update solidity-by-example.rst
made changes suggested to simplify code. Hope this is enough
Thanks
Diffstat (limited to 'docs/solidity-by-example.rst')
-rw-r--r-- | docs/solidity-by-example.rst | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/docs/solidity-by-example.rst b/docs/solidity-by-example.rst index dd208ea3..f5f109fd 100644 --- a/docs/solidity-by-example.rst +++ b/docs/solidity-by-example.rst @@ -171,20 +171,13 @@ of votes. } } + //Calls winningProposal() function to get the index + //of the winner contained in the proposals array and then + //returns the name of the winner function winnerName() constant returns (bytes32 winnerName) { - //Init a for loop that compares all the votes - //one at a time. If a higher count is found, the - //value is updated. p represents position of the - //proposed person's name in the array - uint winningVoteCount = 0; - for (uint p = 0; p < proposals.length; p++) { - if (proposals[p].voteCount > winningVoteCount) { - winningVoteCount = proposals[p].voteCount; - winnerName = proposals[p].name; - } - } + winnerName = proposals[winningProposal()].name; } } |