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

Generator functions/Continuations. #1285

Open
sadmac7000 opened this issue Apr 27, 2015 · 1 comment
Open

Generator functions/Continuations. #1285

sadmac7000 opened this issue Apr 27, 2015 · 1 comment

Comments

@sadmac7000
Copy link

Python has a feature like this and I think it'd be good for Ceylon.

Basically you can do something like this:

{Integer *} myGenerator(Integer start) {
    variable Integer k = start;

    while(k < 10) {
        yield k++;
        print("Yeah!");
    }
}

shared void
run() {
    for (k in myGenerator(7))  {
        print(k);
    }
}

This will print:

7
Yeah!
8
Yeah!
9
Yeah!
@quintesse
Copy link
Member

There was already some discussion about this in #312, #1168 and #1174

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