I'm new to solidity, I'm writing a smart contract for ballot process but getting the error in my ballot
function in the line proposals = proposals.slice(0, _numProposals);
. I've traversed all the relevant questions to it but finally concluded to ask you people when my problem seemed different from others.
pragma solidity ^0.8.10;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
}
struct Proposal {
uint voteCount;
}
enum Stage {Init, Reg, Vote, Count}
Stage public stage = Stage.Init;
address chairperson;
mapping(address => Voter) voters;
Proposal[] proposals;
uint startTime;
/// Create a new ballot with $(_numProposals) different proposals.
function ballot(uint8 _numProposals) public {
chairperson = msg.sender;
voters[chairperson].weight = 2;
proposals = proposals.slice(0, _numProposals);
stage = Stage.Reg;
startTime = block.timestamp;
}
I'm getting the same error after I've also added proposals = proposals.slice[0 : _numProposals];
. Please explain to me in detail what is the root cause?
Thanks in advance.