[Ethereum] In solidity, how can you set a bytes variable to empty

bytessolidity

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

Best Answer

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.