I am trying to initialize this struct and I can't figure out how to pass in a dynamically sized empty array..

      uint8[] id;
  users[msg.sender] = User( true, msg.sender, _username, block.timestamp, block.number, 0, id, 0);

1 Answer 1


The following will work:

contract Test {
    struct Object {
        uint a;
        string b;
        string[] c;
        mapping(uint => uint) d;

    Object field;

    function Test() {
        field = Object({
            a: 1,
            b: "abc",
            c: new string[](0)
  • I get this error when I skip it: Error: Wrong argument count for function call: 7 arguments given but expected 8.
    – ethereal
    Commented Jan 31, 2017 at 0:54
  • My bad, it is mapping that you skip. I updated my answer. Commented Jan 31, 2017 at 9:53
  • Ok great that works!
    – ethereal
    Commented Jan 31, 2017 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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