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
?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With