struct Monster {
uint248 exp;
uint8[] bodyPart;
}
Does Monster struct occupy 1 or 2 uint256
in packing?
What is the size of uint8[ ]
occupation in Struct type
struct Monster {
uint248 exp;
uint8[] bodyPart;
}
Does Monster struct occupy 1 or 2 uint256
in packing?
What is the size of uint8[ ]
occupation in Struct type
Since bodyPart
is a dynamic array, its layout in memory begins with the (256-bit) length of the array, so this structure definitely occupies more than 1 slot.
Note that you haven't shown whether or not this structure is being used in storage to begin with, and that's where the number of slots actually matters.
Thank you your response but I didn't really understand.
If I have two scenarios initialization and assign a new value to uint8[]
after initialization...
how many bytes the two scenarios actually will be used?