I am trying to evolve my understanding of side effects and how they should be controlled and applied.
In the following List of flights, I want to set a property of e
There is nothing wrong with it perse, except that you need to iterate it somehow, like calling Count()
on it.
From a 'style' perspective it is not good. One would not expect an iterator to mutate a list value/property.
IMO the following would be better:
foreach (var x in fResults.Where(flight => flight.NonStop))
{
x.Description = "Fly Direct!";
}
The intent is much clearer to the reader or maintainer of the code.