EatTheBlocks Forum

Solidity question


Can someone explain me what the last line does please?

Thank you

Take care

 struct Candidate {
        uint id;
        string name;
        uint voteCount;

mapping(uint => Candidate) public candidates;
uint public candidateCount;

constructor() public {
    addCandidate("candidate 1");
    addCandidate("candidate 2");

function addCandidate(string name) private {
    candidateCount += 1;
    candidates[candidateCount] = Candidate(candidateCount, name, 0);

It create a Candidate struct and add it to the candidates mapping.

thank you for your answer

1 Like