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);
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityI 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);
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) }); } }
mapping
that you skip. I updated my answer.
– Xavier Leprêtre B9lab
Jan 31 '17 at 9:53