Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Yield break with return value #5032

Closed
jagorath opened this issue Aug 12, 2021 · 0 comments
Closed

Yield break with return value #5032

jagorath opened this issue Aug 12, 2021 · 0 comments

Comments

@jagorath
Copy link

jagorath commented Aug 12, 2021

When breaking an iterator, two statements inside a code block are required, e.g.

if (someCondition)
{
    yield return -1;
    yield break;
}

With a combined return/break statement for example called "yieldlast" (or something less awkward), these four lines could be reduced to one -

if (someCondition)
   yieldlast -1;

Or to avoid new reserved words, yield break could have an optional parameter:

if (someCondition)
   yield break -1;
@svick svick closed this as completed Aug 12, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants