1

Maybe this question it seems to be stupid but is it possible to change elements of fixed-size array like bytes32. For example:

bytes32 _b32 = sha3(1);
_b32[0] = 100; // => Error

1 Answer 1

3

It's possible to mutate elements of a fixed-sized array, but not a fixed-sized byte array (like bytes32).

So this is valid:

byte[32] myBytes;
myBytes[3] = 0x5;

but this is not valid:

bytes32 myBytes;
myBytes[3] = 0x5;  // TypeError: Expression has to be an lvalue.
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.