Remix.run Logo
ambicapter 8 hours ago

They’re both equally bad to me, I don’t see the improvement over just using item.count. I may be nitpicking a toy example though.

Quarrelsome 8 hours ago | parent [-]

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.