Proposal: list-patterns on enumerables #9004
Replies: 4 comments
-
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.
-
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