Runtime: ForEach or Select void to do some logic and continue with the same collection

Created on 12 May 2017  路  3Comments  路  Source: dotnet/runtime

I'm not sure we should add new API or just use Select. But it would be the same argument

```C#
IEnumerable Select(this IEnumerable list,Action action);
IEnumerable Select(this IEnumerable list,Action action);

or

IEnumerable ForEach(this IEnumerable list,Action action);
IEnumerable ForEach(this IEnumerable list,Action action);
```

This let us split iteration logic easier. We could do something before Where clause. We could split it out from Where without the need to return each item unneccessary

api-needs-work area-System.Linq

Most helpful comment

I don't think LINQ should encourage side-effects, especially not in the middle of a query.

Though if this method is added, it should probably stay consistent with Rx, which calls this method Do().

All 3 comments

I don't think LINQ should encourage side-effects, especially not in the middle of a query.

Though if this method is added, it should probably stay consistent with Rx, which calls this method Do().

Please ignore the PRs/merges dotnet/corefx#31991. Wrong issue.

I don't think LINQ should encourage side-effects, especially not in the middle of a query.

Agreed. This goes against the general approach we've tried to maintain with LINQ.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bencz picture bencz  路  3Comments

chunseoklee picture chunseoklee  路  3Comments

v0l picture v0l  路  3Comments

EgorBo picture EgorBo  路  3Comments

matty-hall picture matty-hall  路  3Comments