polyadic / funcky

Funcky is a Functional Library for C#
https://polyadic.github.io/funcky
Apache License 2.0
19 stars 4 forks source link

Deprecate Sequence.Return in favor of collection expressions in C#12 #748

Closed FreeApophis closed 1 year ago

FreeApophis commented 1 year ago

https://twitter.com/davidfowl/status/1701449085784592888

FreeApophis commented 1 year ago

Maybe offer a refactoring...

IEnumerable<int> numbers = Sequence.Return(0, 1, 2)
IEnumerable<int> numbers = [0, 1, 2]
bash commented 1 year ago

One advantage that Sequence.Return has over collection literals is that it doesn't need a target type. This is useful when invoking extension methods:

[1, 2, 3].Select(x => 2 * x); // error CS9176: There is no target type for the collection expression.

Sequence.Return(1, 2, 3).Select(x => 2 * x) // Works!
FreeApophis commented 1 year ago

I think I will close the issue for now.

There are currently quite a few places where we cannot easily replace the call.

For the other places we might want an analyzer: #762