Proposal: Return expression #4492
Answered
by
HaloFour
ronnygunawan
asked this question in
Language Ideas
-
A return expression works similar to throw expression. It invokes a return statement when evaluated. void Hello(Person? p) {
string name = p?.Name ?? return;
Console.WriteLine($"Hello {name}");
}
int? GetAgeOrDefault(List<Person> people, string name) {
Person person = people.FirstOrDefault(p => p.Name == name) ?? return null;
Debug.Assert(person.Age > 0);
return person.Age;
} |
Beta Was this translation helpful? Give feedback.
Answered by
HaloFour
Mar 3, 2021
Replies: 1 comment
-
See: #867 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
333fred
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See: #867