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

feat(foreach): ✨ add statement to exit from a foreach loop #841

Merged
merged 6 commits into from
Apr 5, 2024

Conversation

matteo-cristino
Copy link
Collaborator

No description provided.

@@ -64,3 +64,8 @@ Foreach("'' in sequence from '' to '' with step ''", function(name, from_name, t
end
end
end)

When("exit from foreach loop", function()
Copy link
Member

@jaromil jaromil Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best use:

exit foreach loop

which will support also exit the

unsure if to use break as a verb, more used in other langs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had also the same doubt about using exit or break, maybe break foreach loop can be a better solution, what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are unsure qe can have them as alias both exit and break

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes to aliasing both exit and break.

I checked and the word loop is not mentioned anywhere so:

break foreach
exit foreach

One doubt left since endforeach is used as one word to mark end of branch... I think there will be confusion later on about having the word separated, as well between exit and end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main difference between exit/break foreach and endforeach is that the former is a When statement, i.e.

When I break the foreach

While the latter is just a keyword to mark the end of the code to be repeated in a foreach loop.

To me this separation make sense

@jaromil
Copy link
Member

jaromil commented Apr 5, 2024

I think my doubts can be set aside and as you say it seems coherent to break inside a statement rather than prefix. Merging. Very well done!

@jaromil jaromil merged commit e5f7816 into master Apr 5, 2024
35 checks passed
@jaromil jaromil deleted the feat/exit_from_foreach branch April 5, 2024 13:58
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

Successfully merging this pull request may close these issues.

Iterators variable after foreach loops and transition between foreach loops
2 participants