I have the following contract code example:
contract C {
struct A {
uint256 a;
uint256 b;
}
struct B {
A ax;
uint256 c;
}
struct C {
string name;
B[] bs;
}
function init() {
C memory c;
B memory b;
A memory a;
a.a = 10;
a.b = 20;
b.ax = a;
b.c = 30;
c.name = "Test test test";
c.bs[0] = b;
}
}
Why can't I use push for the last statement
c.bs[0] = b;
:
c.bs.push(b);
It throws the following error:
Untitled:30:9: Error: Member "push" is not available in struct B memory[] memory outside of storage.
c.bs.push(b);
^-------^
but bs is an array of structures.
new
keyword. solidity.readthedocs.io/en/develop/types.html#arrays