-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permit discards in lambda parameters #16255
Comments
I know, that people are going to kill me for saying this, but if I have an older C#-project, in which one lambda has the parameter called <insert worried facial expression> |
I think @gafter means that the '_' parameters are discarded only in the case when there are more than one of them, which is not currently legal in C#. This makes the feature backwards compatible. |
@Unknown6656 That's what I read it to mean. "In this case [the case where there are multiple declarations of parameters named |
We've dropped the term "wildcard" in preference of "discard". "Wildcard" implies regular expressions and some kind of matching, which don't have anything to do with discards. Discards are all about throwing something away. Anyway, they're both cards. |
Any problem with leaving out the discard symbol altogether? For example: |
@janjoostvanzon
Is a single character too verbose?
It would for overload resolution. There could be two |
@HaloFour: I don't feel very strongly about my suggestion, but I do like how 'no character' looks better than the underscore. But 'I just like it better' does make a very strong argument. However, I could argue that no character is more concise than one character. Concise is one of the things I like about the C# language. I think it makes the language more readable. I think no character, nothing, expresses 'do nothing' better than anything. I feel it is a cleaner look. I like this: (int x,,) = GetTuple(); Better than this: (int x, _, _ ) = GetTuple(); Thanks for the feedback. |
@janjoostvanzon Shrug, thinking of LINQ most of the extension methods do have overloads, one for just the element and another for the element and the index. So the issue would be pretty common there. And no character is less than one character, but it's still a very minor difference. The use of |
This has been moved to dotnet/csharplang#111 |
Please permit a lambda to have multiple declarations of parameters named
_
. In this case the parameters are "discards" and are not usable inside the lambda.The text was updated successfully, but these errors were encountered: