11

I make some contracts code with mapping data. When I first access data value, ethereum returns 0.

Is it specification of ethereum? In other word, Can I write a contract on the assumption that variable's initial value is 0?

  • 1
    Possible duplicate of [Are there null like thing in solidity](http://stackoverflow.com/q/37852682/1260906). See also [this](http://ethereum.stackexchange.com/a/2134/87), [this](http://ethereum.stackexchange.com/q/2502/87) and [this](http://ethereum.stackexchange.com/q/5683/87) over at [Ethereum Stack Exchange](http://ethereum.stackexchange.com/). – q9f Jul 18 '16 at 08:08

1 Answers1

13

Yes, this is the default behavior. Each types have a "zero-state" default value. For example boolean have a default value of false, integer a default value of 0 and strings a default value of ""

You can read more here http://solidity.readthedocs.io/en/develop/control-structures.html#default-value

AlexN
  • 156
  • 1
  • 6