|
|
|
|
|
by Quarrelsome
143 days ago
|
|
I think in this case itemCount had application in a couple of conditions later in the function, so there was value in extracting the count. In my recollection I might be missing some nuance, lets say for the sake of argument it was: var relevantCount = items.Where(x => x.SomeValue > 5); vs var numberOfRelevantItems = items.Where(x => x.SomeValue > 5); so it wasn't necessarily cheap enough to want to repeat. |
|
Here though you're missing the ".Count", so
As long as it's not a property that's calculated every time it's accessed, this still seems better than pulling the count into its own variable to me.