0/5
_You can follow along with the video course from here._ ### Introduction In this section, we'll focus on one of the final steps to complete the `withdraw` function: effectively resetting the `funders` array. ### Resetting an Array The simplest way to reset the `funders` array is similar to the method used with the mapping: iterate through all its elements and reset each one to 0. Alternatively, we can create a brand new `funders` array. ```js funders = new address[](); ``` > 🗒️ **NOTE**:br > You might recall using the `new` keyword when deploying a contract. In this context, however, it resets the `funders` array to a zero-sized, blank address array. ### Conclusion In this lesson, we learned how to reset the `funders` array by either iterating through its elements or creating a new zero-sized array. This step is crucial for completing the `withdraw` function and ensuring the contract's data is properly managed. ### 🧑💻 Test yourself 1. 📕 Why is it important to reset the `funders` array when implementing the `withdraw` function? 2. 🧑💻 Create a method `expensiveReset` that resets an array using the iteration method.
You can follow along with the video course from here.
In this section, we'll focus on one of the final steps to complete the withdraw
function: effectively resetting the funders
array.
The simplest way to reset the funders
array is similar to the method used with the mapping: iterate through all its elements and reset each one to 0. Alternatively, we can create a brand new funders
array.
🗒️ NOTE:br
You might recall using thenew
keyword when deploying a contract. In this context, however, it resets thefunders
array to a zero-sized, blank address array.
In this lesson, we learned how to reset the funders
array by either iterating through its elements or creating a new zero-sized array. This step is crucial for completing the withdraw
function and ensuring the contract's data is properly managed.
📕 Why is it important to reset the funders
array when implementing the withdraw
function?
🧑💻 Create a method expensiveReset
that resets an array using the iteration method.
A guide on effectively resetting arrays in Solidity, particularly within the context of smart contracts. The lesson addresses the importance of resetting arrays for managing and updating contract states, and demonstrates the process using practical examples.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Blockchain developer fundamentals
Smart contract ABI
Solidity Smart contract development
Solidity Safemath
Solidity custom errors
Solidity inheritance
Solidity gas optimization techniques
Solidity and Ethereum developer workflow
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Guest lecturers:
Last updated on July 7, 2025
Duration: 1h 46min
Duration: 38min
Duration: 2h
Duration: 23min
Course Overview
About the course
Blockchain developer fundamentals
Smart contract ABI
Solidity Smart contract development
Solidity Safemath
Solidity custom errors
Solidity inheritance
Solidity gas optimization techniques
Solidity and Ethereum developer workflow
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Guest lecturers:
Last updated on July 7, 2025