What is the initial value of Ethereum contract variables?
Asked Answered
W

1

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?

Worden answered 18/7, 2016 at 2:28 Comment(1)
Possible duplicate of Are there null like thing in solidity. See also this, this and this over at Ethereum Stack Exchange.Bistoury
S
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

Seneca answered 20/9, 2016 at 11:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.