Can I Clear a Struct from a Mapped Variable?

SilentCiceroSilentCicero Toronto, CAMember Posts: 159 ✭✭✭
contract StructProblem
{
    struct CodeData
    {
        address owner;
    }
    
    mapping (uint => CodeData) data;
    mapping (address => uint) toCode;

    function clear_data(uint code)
    {
        toCode[msg.sender] = 0; // Works fine.
        data[code] = ""; // <-- How do I clear this data?
    }
}
I get a "Type error: Assignment to non-local non-value lvalue." which is understandable. I cant set data[code] to a string and I'm not changing a var in the struct such as: "owner".

How can I clear data[code] of the struct type CodeData?

What is good practice?

I was thinking of just clearing all values inside the struct such as "owner". Is this all I can do for now?


Cheers.

Comments

Sign In or Register to comment.