pragma solidity 0.4.25;
contract A{
struct N{
string any;
uint256[] numberArray;
}
N[] public numbers;
function init(uint256[] _numbers) public{
for (uint256 i = 0; i < _numbers.length; i++) {
uint256[] memory arr;
arr[0] = _numbers[i];
numbers.push(N("anything", arr));
}
}
}
This contract compiles but throws:
transact to A.init errored: VM error: invalid opcode.
invalid opcode The execution might have thrown.
What I wish to achieve
Example call:
init([1,2,3,4,5])
Outcome:
N[0] = "anything", [1]
N[1] = "anything", [2]
N[2] = "anything", [3]
N[3] = "anything", [4]
N[4] = "anything", [5]
Afterwards I would like to be able to push to the array within the array.