IEnumerable in Unity

That´s right, I´m not asking about IEnumerators, I know how to start a coroutine. The thing is that I have been trying to improve my understanding of yield in C#, and I noticed that in the microsoft documentation the don´t use IEnumerator at all when using yield, in fact it looks to me that they are trying to avoid it to keep things simple.

So, what uses would IEnumerable have in Unity? why is IEnumerator used with yield and not IEnumerable?

There’s nothing special about these interfaces in Unity, aside from Unity using an outdated version of Mono, making them less efficient than we’d all like. I still use IEnumerable a ton, due to LINQ making code shorter and more easily readable. It doesn’t make sense to use a garbage collected language for game development, but that’s what we’ve got, so embrace the suck! :stuck_out_tongue: Alter your code to something more archaic, after profiling, if necessary.

which links to more good answers:

Despite heavy use of IEnumerable, I never find myself having to implement IEnumerator itself. (These two Interfaces should be generic, with two arrows and a T in the middle, but the site makes them disappear. Please edit this if you know how to bring them back. I never use the non-generic forms.)