Using Arrays Within Solidity Structs

Abstract contracts and interfaces share some similar characterstics but they are different.

memory variables are temporary variables that exist only inside the calling function. The memory variables do not persist and are generally cheaper to use than storage variables.

storage variables are stored in contract state and are only changed by sending a transaction and spending gas.

pragma solidity ^0.7.0;

contract ArrayInsideStruct {

  event CreateGame(address indexed _from, uint256 _value);

  struct Game {
    address[] users;
    uint256 gameId;

  Game[] public games;

  function createGame() public {

      // initialize struct with empty new array of size 0
      Game memory game = Game(new address[](0), 0);


      // push data to the array inside struct

      CreateGame(msg.sender, games.length-1);
  function getUsers(uint i) public view returns (address[]){
      return game[i].users;