Reference GameObjects from an Array (938652)

Ok, this may be simple but I can’t figure out how to do this… I want to call multiple gameobjects from an array with just a couple of lines.
As you can see, I want some of the gameobjects Active and some NonActive, but this isn’t working. Any help will be Greatly Appreciated!

public class Puzzle_Idol : MonoBehaviour
    {
        public GameObject IdolContainer;
        public GameObject[] Idol;
   
        public int IdolPosition = 1;
        public AudioSource IdolSelectSound;
   
        public GameObject Player;
        [SerializeField] public int distanceFromPlayer = 5;
   
        void Start()
        {
            for (int i = 0; i < Idol.Length; i++)
            {
//This is where I'm lost. There must be a simple way of doing this. I've tried using commas. 
                Idol[5 & 6 & 7 & 8].SetActive(false);
                Idol[0 & 1 & 2 & 3 & 4].SetActive(true);
            }
        }
    }

No that’s not valid C# syntax at all. An indexer for an array/list accepts one integer only. You can only get one object out of it at a time.

You need to use math or whatever logic to figure out your indexes and use that to set whatever ones you want to active, and the others to inactive. Or just grab each game object one by one and then workout whether it should be active or not.

For example here’s how you’d set every odd game object inactive:

void Start()
{
    for (int i = 0; i < Idols.Length; i++) // collections should really be named appropriately
    {
        GameObject idol - Idols[i]; // just grab the game object first
        bool isEven = (i % 2) == 0;
        idol.SetActive(isEven);
    }
}
void Start()
{
    for (int i=0;i<Idol.Length;i++)
        Idol[i].SetActive(Random.value>0.5f); // A 50% chance of being active
}

Based on your example:

for (int i = 0; i < Idol.Length; i++)
{
  Idol[i].SetActive(i < 5);
}