13

Zero values, as in what would placehold the value when a key in a mapping is not yet assigned.

2

1 Answer 1

35

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 enum

  • address: 0x0000000000000000000000000000000000000000 (or address(0))

  • function

    • internal: empty function, returning initial values (if return is needed)
    • external: function that throws when called
  • Reference Types

  • mapping: empty mapping

  • struct: a struct where all members are set to initial values

  • array

    • dynamically-sized: []
    • fixed-sized: an array of the fixed size where all elements are set to initial values

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.

2
  • 2
    How do I check if in mapping(uint8 -> address) testMap the address is still initial value? Is this correct: testMap[0] == address(0)?
    – Jagrut
    Feb 25, 2019 at 14:23
  • 1
    @Jagrut Use testMap[0] == 0x0
    – Kuelf Deez
    Mar 15, 2021 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.