The Wayback Machine - https://web.archive.org/web/20160630200910/http://ethereum.stackexchange.com:80/questions/6618/in-solidity-how-can-you-set-a-bytes-variable-to-empty
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the crypto value and blockchain-based consensus network. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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.

share|improve this answer
    
Thanks eth! Always appreciated. – Aakil Fernandesyesterday
    
Thanks @AakilFernandes for helping build up a knowledgebase for all! – eth13 hours ago

Not the answer you're looking for? Browse other questions tagged or ask your own question.

close