For expl.
mapping(uint => Test) tests;
struct Test {
uint id;
mapping(address => uint) votes;
}
function newTest() public {
test[0] = Test(0, <EMPTY_MAPPING>)
}
For expl.
mapping(uint => Test) tests;
struct Test {
uint id;
mapping(address => uint) votes;
}
function newTest() public {
test[0] = Test(0, <EMPTY_MAPPING>)
}
You can rewrite your code like this:
tests[0] = Test({
id: 0
});
Solidity will make votes an empty mapping by default. Btw, there's also a typo in your code: should be tests[0] instead of test[0].
Test storage test = tests[0]; test.id = 0;
– Adham
Mar 12 '23 at 21:59