Zero values, as in what would placehold the value when a key in a mapping is not yet assigned.
1 Answer
In Solidity docs they are called initial values:
Value Types
boolean
:false
string
:""
int
:0
uint
:0
fixed
:0.0
(presumably; this type is not fully supported)enum
: the first element of the enumaddress
:0x0000000000000000000000000000000000000000
(oraddress(0)
)function
internal
: empty function, returning initial values (if return is needed)external
: function that throws when called
Reference Types
mapping
: empty mappingstruct
: a struct where all members are set to initial valuesarray
- dynamically-sized:
[]
- fixed-sized: an array of the fixed size where all elements are set to initial values
- dynamically-sized:
When you use the delete
keyword it will assign the initial value to the variable, except for mappings, where it doesn't have any effect. For structs the delete
keyword will recurse into the members, unless they are mappings.
-
2How do I check if in
mapping(uint8 -> address) testMap
the address is still initial value? Is this correct:testMap[0] == address(0)
?– JagrutFeb 25, 2019 at 14:23 -
1