Allow immediate execution of lambdas with implicit return type #7728
-
Currently immediate execution of lambda with implicit return type throws List<Task> tasks = [];
string s;
tasks.Add((async () => s = await GetStringAsync())()); // CS0149: Method name expected
tasks.Add(((Func<Task>)(async () => s = await GetStringAsync()))()); // OK
var getTask = async () => s = await GetStringAsync();
tasks.Add(getTask()); // OK
Task<string> GetStringAsync() => throw new NotImplementedException(); Motivation is: I want to add task to a list witch will be awaited with |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
See: #4748 Which was considered "universally disliked" by the language design team. |
Beta Was this translation helpful? Give feedback.
See: #4748
Which was considered "universally disliked" by the language design team.