The easiest way to think of it is “are we done yet?”
In a standard coroutine (IEnumerator) where your goal is to do something over a period of time instead of all in the same frame, you might delay with
yield return new WaitForSeconds(.1f);
In an IEnumerator, you must have at least one yield return statement, and to exit a coroutine early, you would use yield break instead of return.
IEnumerables are a bit different. Since an IEnumerable is a collection, you can yield return an individual element in a collection, or you can return a collection. In the RPG course, we’re just using it for IModifierProviders, so our IEnumerable is
IEnumerable<float> GetAdditiveModifiers()
In this case, we’re checking to see if we have the modifier in the category requested, and if we do, we yield return a single float value.
Now suppose you had a List<float> someFloats
and you wished to return all of the elements in the list… Since a List is also an IEnumerable, you could simply return someFloats;
and all of the elements would be returned to the collection (and the method would also end).