Definition:
mapping(address => data) clusterContract;
struct data { //defined inside a Library.
mapping(address => Library.Struct[]) my_status;
}
data list;
clusterContract[id] = list;
Usage:
clusterContract[msg.sender].my_status[id].push( Library.Struct({ status: status_ }));
delete clusterContract[msg.sender].my_status; //<=error occurs.
Error occurs:
Error: Unary operator delete cannot be applied to type
mapping(address => struct ReceiptLib.Status storage ref[] storage ref)
E delete clusterContract[msg.sender].my_status;
On the other hand: delete clusterContract[msg.sender].my_status[id] works.
=> Does delete clusterContract[msg.sender] removes(initialise to 0) complete array of my_status as well?
[Q] How could I apply delete to complete storage ref[]? or do I required to iterate ref[](keep track of the ids) and apply delete one by one as shown on the example?
Example:
for (int i=0;i<storedIDs.size();i++)
delete clusterContract[msg.sender].my_status[storedIDs[i]];
Thank you for your valuable time and help.
throwfor the user who want to access the data? The thing is there could be delete operation and via same id it can be re-created. @Rob Hitchens – alper Apr 07 '17 at 07:39status.length = 0do the job. – alper Apr 07 '17 at 08:19my_status[id].length. Since I do not know the keys, I do also need to store them to be able to access them again to initialise their length to 0. @Rob Hitchens – alper Apr 07 '17 at 08:41State Tree Pruningand should be done when ever possible to reclaim disk space. – o0ragman0o Apr 07 '17 at 11:40