Lambda expressioned pattern matching #8897
Replies: 3 comments 7 replies
-
There is something like it already, but it requires moves it after a - [{} first { it => it.StartsWith("a", StringComparison.OrdinalIgnoreCase) },..] => "first element starts with 'a'",
+ [{} first, ..] when first.StartsWith("a", StringComparison.OrdinalIgnoreCase) => "first element starts with 'a'", |
Beta Was this translation helpful? Give feedback.
5 replies
-
See #8613, which covers this type of case. |
Beta Was this translation helpful? Give feedback.
2 replies
-
Thanks for discussion. I will close our conversation. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In my opinion C# language is missing some pattern matching features at least most important is lambda expression in matching clause.
This is strongly inspired by groovy https://blog.mrhaki.com/2009/08/groovy-goodness-switch-statement.html
case { it instanceof Integer && it < 50 }
Having this feature build in language I could imagine that all kind of problems would be easly solved (regex, string comparisions, more complex scenarios)
Example of usage (which doesn't require keyword
when
afterwards pattern) :Please shere your feedback on this feature and vote for more detailed discussion.
Beta Was this translation helpful? Give feedback.
All reactions