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
?
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
© 2022 - 2024 — McMap. All rights reserved.