GridSystemVisual.HideAllGridPositions() Loop Question

In Start() we place each single visual in an array. Why do we then use x and z to discretely pick elements out of that array rather than simply looping through it directly? E.g. (note my GridSystemCellVisual = GridSystemVisualSingle):

    public void HideAllGridPositions() {
        foreach (GridSystemCellVisual gridSystemCellVisual in gridSystemCellVisualArray) {
            gridSystemCellVisual.Hide();
        }
    }

This was how I implemented it for the challenge, and it works, but I’m not sure if I’m missing something or if there might be a flaw that will pop up later.

There is nothing wrong with this approach, as long as the operation is on all GridPositions. There are often many paths to the same goal.

Got it. I was just wanting to make sure there wasn’t any specific reason to use double indexes that might become relevant later. That has happened to me before when I second guessed Hugo in his free course. :wink:

Sounds like I should be good to go. Thanks!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms