As far I know, new address[](number)
creates an fixed sized array of that number initialized with zero. But how in this line Room memory room = Room(new address[](0), 0, 0);
Room struct is taking an empty array and later how an address is going to be put there?
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[](0), 0, 0);
rooms.push(room);
rooms[rooms.length-1].players.push(msg.sender);
OnCreateRoom(msg.sender, 0);
}
function getRoomPlayers(uint i) public view returns (address[]){
return rooms[i].players;
}
}