delay in IEnumerator Start() causes error in update() function

I have this code `

IEnumerator Start()
    {
        yield return new WaitForSeconds(1.0f);
        \\some code
   }

void Update () {
    Instantiate(cars[carList[a]], carpos, transform.rotation);
   //some code
}

problem is the update() starts even the start() function hasn’t ended yet. What should i do so that the update() functions starts after start() function delay.

Short circuit the update function with a bool? Using a public variable like a callback…

public bool startFinished = false;

void Update () 
{
  if(startFinished)
  {
    //do stuff in update loop
  }
}

IEnumerator Start()
{
  yield return new MyFunction(); // I am assuming you want start() to be IEnumerator to yield it
  startFinished = true;
}

I think if you instantiate things in Update() you’re gonna have a bad time