1

For expl.

mapping(uint => Test) tests;

struct Test {
    uint id;
    mapping(address => uint) votes;
}
function newTest() public {
    test[0] = Test(0, <EMPTY_MAPPING>)
}
1
4

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].

1
  • Wrote that in Stackexchange instead of int he IDE. Thanks Paul that'll do it, I could not find the question you asked earlier.
    – jasper
    Nov 21 '18 at 13:19

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