Skip to content

Default Values for Solidity Types

Wyatt Barnes edited this page Feb 14, 2019 · 1 revision

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: 0x0
  • 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.

Clone this wiki locally