-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: Trailing return type #8448
Comments
Or you can manually select the overload by writing: Body = Activities.Invoke<int>(action: i =>
{
runCount++;
throw new Exception("broke");
}), Which is sometimes the only possible solution to this problem. |
Currently you can also explicitly cast the expression to Action or call the constructor.
|
This is already discussion-ed. |
I am not sure of your point. I was just adding additional relevant information to the discussion and to present existing alternatives which may or may not highlight the need for the issue. |
Closing as dup of #13744 |
From #7681:
To not fall into that kind of situations, where compiler would infer the return type, and you'll need to trick it to understand what you meant, one should be able to explicitly declare lambda's return type to prevent accidental mess-up, e.g.
One other use case is that when the return type is rather complicated, like intersection types (#4586), tuples (#347), etc, which causes a "weird" method signature,
And honestly, tuple type syntax doesn't look well with C-like return types,
This would also address the backward declaration of type parameters.
PS: I'm not proposing return type inference, so presence of
auto
orvar
or none is up for discussion.The text was updated successfully, but these errors were encountered: