diff --git a/book/book/Array.html b/book/book/Array.html index e861ba8..10b844a 100644 --- a/book/book/Array.html +++ b/book/book/Array.html @@ -179,7 +179,7 @@

Array Storage Index 5 => keccak256(c) + 5

Which is the 6th element.

Reading From An Array

-

While reading the elements of the fixedU256Array is simple, because, type uint256 takes up 32 bytes, the same cannot be said for the fixexU8Array as they're packed and care would be taken to avoid messing up the value stored at that slot. We can always call an sload(slot) to get the value of any index stored at any slot.

+

While reading the elements of the fixedU256Array is simple, because, type uint256 takes up 32 bytes, the same cannot be said for the fixedU8Array as they're packed and care would be taken to avoid messing up the value stored at that slot. We can always call an sload(slot) to get the value of any index stored at any slot.

However, for fixedU8Array on initialization:

contract Array {
     uint8[3] public fixedU8Array;
@@ -193,7 +193,7 @@ 

R

Once the slot where the values of the fixedU8Array has been located, which we shall address as loc, we can call a simple sload(loc) to get the value stored at that slot, which will be returned as:

0x0000000000000000000000000000000000000000000000000000000000030201
 
-

It will be packed, as stated earlier. We can then use a masking to return any index in the array based of the uint8 type, 1 byte by calculating its offset precisely.

+

It will be packed, as stated earlier. We can then use a masking to return any index in the array based on the uint8 type, 1 byte by calculating its offset precisely.

More Info

Click to read more.