New answers tagged

1

The increment people count is added before adding the person to the mapping. So nothing is added to the people[ 1 ] spot in the mapping. As is, the first spot in the mapping that gets filled is people[ 0 ]. Move incrementCount() to after adding the person to the mapping.


1

Person is declared as an array of structure having a variable people. But with ‘people’ we are not using square brackets. Is this not required in Solidity? When can we use square brackets with 'people'? That's wrong, Person is just a structure type name; Person[] people is an array of structures. You typically use square brackets in Solidity when you want ...


1

First of all, you are using People, while the name of your variable is people. Second, you can call push on an array, but you are trying to call it on an array element. In short, replace this: People[0].push(...); With this: people.push(...);


1

nested hell Yup. This is circular: struct B { B[] as; } B contains arrays of B? The dynamic array of a struct inside a struct pushes the limits of what the compiler can handle. You would have to construct a memory instance of the struct and use the push method, which isn't present and then copy the works into storage. As a general suggestion, ...


0

It looks like this example may fit for you: pragma solidity ^0.4.18; contract StructArrayInit { event OnCreateRoom(address indexed _from, uint256 _value); struct Room { address[] players; uint256 whosTurnId; uint256 roomState; } Room[] public rooms; function createRoom() public { Room memory room = Room(new address[]...


Top 50 recent answers are included