You are viewing a single comment's thread from:
RE: What the hell does C# yield do?
Yep, it gets complex. The key to it is that you avoid mutation of any state and there is 0 risk. If you have mutation then the problem is you have no idea when code will run and hence when the mutation will take place.
In C# you can force evaluation early
var oldPeople = people.Where(persion => person.Age >= 65).ToArray();
The ToArray() forces all the code to execute there and then, removes the lazy state