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

Unreadable code #73

Open
Neutrino-Sunset opened this issue Dec 8, 2020 · 2 comments
Open

Unreadable code #73

Neutrino-Sunset opened this issue Dec 8, 2020 · 2 comments

Comments

@Neutrino-Sunset
Copy link

This is just painful to look at.

public IHttpProxyBuilder WithEndpoint(string endpoint) => this.WithEndpoint((context, args) => new ValueTask<string>(endpoint));

A method implemented as a lambda, multiple lambdas at that, one implementation delegating to something that reads almost like an overload (WithEndpoint -> WithEndpoints). All on a single line. This kind of thing is programmer trolling.

@szalapski
Copy link
Contributor

The method isn't a lambda, it is a expression-bodied method. The body itself is a lambda. I am used to working with the => operator pervasively. I think I'd split this into two lines, but that's all I'd change. Just my opinion.

@szalapski
Copy link
Contributor

szalapski commented Dec 8, 2020

public IHttpProxyBuilder WithEndpoint(string endpoint) => 
    this.WithEndpoint((context, args) => new ValueTask<string>(endpoint));

or, in C#9:

public IHttpProxyBuilder WithEndpoint(string endpoint) => 
    this.WithEndpoint((_, _) => new ValueTask<string>(endpoint));

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