August 2019
Intermediate to advanced
486 pages
13h 52m
English
The delete keyword is used to reset the values of some data type and complex types such as arrays and structs. For example, if delete is used on int/uint, its value will be set to 0, which is the default value of the data type:
uint a = 1;function reset() public { delete a; //resets the value of a = 0 }
In the same way, delete can also be used to reset the array types, where it assigns a dynamic array of length 0 if the array is a dynamic array. If an array is a static array, it resets all elements and keeps the length of the array same.
When the delete keyword is used for a struct, it resets all of the variables of the struct to their respective default values.
For mappings, you can reset a value ...