Can anyone help me with the correct syntax for pushing variables to arrays within arrays? I have searched many threads but found nothing that exactly answers my query.
I have a class (Brigade) which amongst other variables contains an array (BrigadeUnits) This is the third element… My Brigades are stored in an array called AllBrigades. I now need to fill the BrigadeUnits array with objects of my Units class.
The hierarchy I want to create is as follows:
AllBrigades (array of Brigades)
Brigade (object)
BrigadeUnits (array within Brigade object)
Unit (Object to be stored in BrigadeUnits array)
I hope this makes sense!
I have tried various approaches including the following, assuming that I am addressing the first Brigade in the array:
AllBrigades [0] [2].push (MyUnit);
But when I trace this I just get undefined.
Where am I going wrong?