I am wrapping my head around Coroutines and yield (and indirectly WaitForSeconds) and have noticed an inconsistency that initially caused me a lot of pain in sorting out why code had errors.
The main thing I’m noticing is that here, the documentation shows use of WaitForSeconds without creating a new object:
Code example from the first link:
// Prints 0
print (Time.time);
// Waits 5 seconds
yield WaitForSeconds (5);
// Prints 5.0
print (Time.time);
That however gives me compile errors. If I use this, below, I do not get compile errors:
// Prints 0
print (Time.time);
// Waits 5 seconds
yield return new WaitForSeconds (5);
// Prints 5.0
print (Time.time);
My question is WHY do the examples from official documentation result in compile errors?