Proposal: list-patterns on enumerables #9004
Replies: 5 comments 10 replies
-
why not |
Beta Was this translation helpful? Give feedback.
-
It's not a new language feature. It already exists for indexable collections, like arrays and lists. |
Beta Was this translation helpful? Give feedback.
-
[1; x] feels like a (personally) long awaited pattern matching on non const values rather that x being a declared variable here. Also, as stated above it's already a feature on indexable types. It's just that it's harder to do properly with sequences because it most likely will result in implicit buffering in complex cases like [1, ..var x, 5] which might be not desirable. At least with indexable collections this behavior is explicit and based on public members of those collections. |
Beta Was this translation helpful? Give feedback.
-
Proposal revamped: https://github.com/dotnet/csharplang/pull/9165/files?short_path=842dc5b#diff-842dc5be20dd67a91231b72c300d0bc365040809d32c98dee0e4e166e53191bc |
Beta Was this translation helpful? Give feedback.
-
I know that languages have to walk the fine line between "pit of success" for developers and providing useful/powerful features that have potential for misuse. I could go either way on this one, but my question to the community is which side of the line people fall on for this feature? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Allow
is [ 1, 2, 3 ]
(list pattern) andis [ 1, ..var x, 5 ]
(slice pattern) on enumerables.Champion issue: #9005
Background:
Design meetings:
Beta Was this translation helpful? Give feedback.
All reactions