I tried this
contract MyContract{
bytes public data = 0x3333;
function clearData(){
data = 0x;
}
}
But solc doesn't like me trying to set data to 0x
Use ""
.
contract MyContract{
bytes public data = "0x3333";
bytes public empty;
function clearData(){
data = "";
}
}
Tested using https://ethereum.github.io/browser-solidity by looking at the value of data
and empty
.
delete data;
Source http://solidity.readthedocs.io/en/develop/types.html
delete a assigns the initial value for the type to a. I.e. for integers it is equivalent to a = 0, but it can also be used on arrays, where it assigns a dynamic array of length zero or a static array of the same length with all elements reset. For structs, it assigns a struct with all members reset.