Why is data location not required to be specified for bytes32?
-
Hello. Please give us more details about your question. What do you mean by "data location not required" ? What exactly are you talking about ? What type would require it ?– Itération 122442May 3, 2021 at 9:07
-
2@FlorianCastelain In solidity, there are 4 types of data location: storage, calldata, stack and memory. Data location must be explicitly specified in solidity for arrays, bytes and structs.– Rachid AtmaiMay 3, 2021 at 20:06
1 Answer
Whether or not you need to declare memory
, storage
, or calldata
depends on if your variable is a "complex" variable or not. (See the note here.) This means things like structs and arrays. Simpler types are automatically assigned storage
- see this question and anwser.
To answer fully, bytes32
will automatically be storage
even without a data location declaration.
-
1
-
bytes
is a monster that probably should have gotten a different name to distinguish it further from the simple types likebytes32
.– eth ♦May 7, 2021 at 1:25