Skip to content
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

Proposal: Lambda Wildcards #15027

Closed
HaloFour opened this issue Nov 5, 2016 · 3 comments
Closed

Proposal: Lambda Wildcards #15027

HaloFour opened this issue Nov 5, 2016 · 3 comments

Comments

@HaloFour
Copy link

HaloFour commented Nov 5, 2016

This is an extension to #14862 and #14794.

I propose that when a lambda is declared using multiple _ identifiers for parameter names that all of those identifiers are then considered wildcards and attempting to reference those parameters in the lambda body is a compiler error. However, if there is only a single parameter with that name then it may be referenced in the lambda body to retain backwards compatibility.

Func<int, int, bool> func1 = (_, _) => true; // legal
Func<int, int, bool> func2 = (_, _) => _ + 4; // CS0103: The name '_' does not exist in the current context
@vbcodec
Copy link

vbcodec commented Nov 5, 2016

It is alerady included in #14794, see end of 'Wildcards (revisited)' section

@HaloFour
Copy link
Author

HaloFour commented Nov 5, 2016

@vbcodec

I believe that #14862 would supersede that behavior and that wildcards wouldn't just result by attempting to declare multiple variables of the name _ in scope.

However, if those proposals combined (and implemented) still results in wildcards for lambda declarations then I will close this proposal.

@HaloFour
Copy link
Author

HaloFour commented Nov 5, 2016

Rereading #14794 it does appear to cover this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants