0

I am trying this:

address[][] memory mintQuantity = new address[][](2);
mintQuantity[0][0] = address(0);
mintQuantity[1][0] = address(0);

But keep getting an error:

[FAIL. Reason: Index out of bounds]

I have tried multiple variations of new address[][](2) but can't seem to get it right.

Doing this with a One-Dimensional Array works fine.

1 Answer 1

1

The new address[][](2) is allocating an array for two address[] but it is not allocating the address[].

address[][] memory mintQuantity = new address[][](2);
mintQuantity[0] = new address[](3);
mintQuantity[1] = new address[](5);
mintQuantity[0][0] = address(0);
mintQuantity[1][0] = address(0);
2
  • Thank you! What exactly does the (3) in address[](3) mean? My understanding is an address[] with 3 possible values passed as a constructor for the Type?
    – Alex
    Jun 21 at 2:07
  • @Alex It is the array length. The syntax new Type[](N) allocates an array of Type with N elements.
    – Ismael
    Jun 21 at 4:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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