0

I have:

mapping (uint256 => uint64[]) public Arry;

I am trying to do:

Arry[123][0]++;

And I am getting the generic invalid opcode.

To me, I am accessing map key 123 which is a uint64 array. I am then incrementing the uint64 in position 0 by one. I don't understand why it dies here.

1 Answer 1

2

Arry[123][0] is out of bounds if Arry[123] has a length of 0. Make sure the array has at least one element in it.

Your code works fine for me as long as I do Arry[123].push(0) somewhere first.

1
  • You're right. It worked after I deleted my build folder and ran truffle test. Commented Jan 14, 2018 at 2:44

Your Answer

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

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