3 ms·
Here's one thing to keep in mind. They both end up doing the same thing, but it's more obvious that the Where implementation is not doing anything subtly differ
by kosievdmerwe 10y ago
Here's one thing to keep in mind. They both end up doing the same thing, but it's more obvious that the Where implementation is not doing anything subtly different from what you think at first glance.
Without reading the for implementation carefully it's much harder to verify:
* You're looping from start to finish
* Over each element
* You're only adding the items to the new list that match the conditions.
That all said, I think this swap is only a good idea if the thing you're swapping with is commonly used. Which admittedly is a chicken-and-egg problem, but does largely exclude non-library function transformations or one-off transformations.