Lesson 4 - Re: creating a new empty array #6495
Unanswered
yuyangezheng
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The below code is the withdraw function of FundMe.sol.
function withdraw() public {
for (uint i=0; i < funders.length; i++) {
address funder = funders[i];
addressToAmountFunded[funder]=0;
}
funders = new address;
}
In the last line, we reset our funders array to a new empty array of length zero. I was wondering why must we use this notation for creating the empty array and why we cannot use funders = address[] instead. Also won't the code as written create a static array of length zero rather than a dynamic array as we had previously?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions