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

Support For Else Statement #14

Open
oovm opened this issue Jun 16, 2023 · 0 comments
Open

Support For Else Statement #14

oovm opened this issue Jun 16, 2023 · 0 comments
Assignees
Labels
Syntax Support new syntax

Comments

@oovm
Copy link
Member

oovm commented Jun 16, 2023

for i in [1, 2, 3] if i % 2 == 0 {
    do_something(i)
}
else {
    do_something_else()
}

Equivalent to

let mut $iter = IntoIterator::into_iterator([1, 2, 3])
let mut $next = $iter.next()
let mut $no_run = true;
while $next.is_some() {
    let i = $next!;
    if i % 2 == 0 {
        $no_run = false;
        do_something(i);
    }
    $next = $iter.next()
}
if $no_run {
    do_something_else();
}
@oovm oovm self-assigned this Jun 16, 2023
@oovm oovm added the Syntax Support new syntax label Jun 16, 2023
@oovm oovm added this to the Version 2020 milestone Jun 16, 2023
@valkyrie-language valkyrie-language locked as resolved and limited conversation to collaborators Jun 16, 2023
@oovm oovm removed this from the Version 2020 milestone Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Syntax Support new syntax
Projects
None yet
Development

No branches or pull requests

1 participant