docs/reference/src/documentation/operations/storage/init.md
Storage is declared through the use of the storage keyword.
Inside the storage block each variable is named, associated with a type and a default value.
{{#include ../../../code/operations/storage/empty_storage_init/src/main.sw:initialization}}
In the following example we will take a look at two ways of storing a struct.
storage blockWe'll begin by defining the Owner & Role data structures and implement a default constructor on the Owner.
{{#include ../../../code/operations/storage/storage_init/src/main.sw:data_structures}}
Now that we have our data structures we'll keep track of how many current_owners we have and declare the owner in the two aforementioned styles.
{{#include ../../../code/operations/storage/storage_init/src/main.sw:initialization}}
An explicit declaration is likely to be sufficient for most types. However, it may be preferable to encapsulate the initialization of complex types within a constructor in order to keep the code concise.
Note that the constructors used in storage blocks must evaluate to a constant during compilation.