dappuniversity / election

A Decentralized Ethereum Voting Application Tutorial
564 stars 506 forks source link

why we not use array for "candidates" ? #6

Open tanpv opened 6 years ago

Bgumel commented 6 years ago

Because candidates has attributes (id, vote count)

tanpv commented 6 years ago

I mean array of candidate object.

iridescent995 commented 6 years ago

I found this in solidity docs "Mappings can be seen as hash tables which are virtually initialized such that every possible key exists and is mapped to a value whose byte-representation is all zeros: a type’s default value. The similarity ends here, though: The key data is not actually stored in a mapping, only its hash used to look up the value.". I think this is the reason.

and we get a free getter method in mapping, so why not use it :)