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

Cannot Exit For Loop in Kahroba #29

Open
alidehkhodaei opened this issue Mar 1, 2023 · 0 comments
Open

Cannot Exit For Loop in Kahroba #29

alidehkhodaei opened this issue Mar 1, 2023 · 0 comments

Comments

@alidehkhodaei
Copy link
Contributor

alidehkhodaei commented Mar 1, 2023

Hello, I want to write an algorithm and I need to stop a loop under certain conditions, but it's not possible. For example, in the linear search algorithm, I need to stop the loop after finding the index. Break and return statements are not effective in stopping the loop in the given conditions. Other example: It works like continue keyword in some language for example Java.

fn test(){
for i in 1..5 {
if i == 3 {
3
}
println(i)
}
}

test()

// Actual output:
1
2
4
5

// Expected output:
1
2

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

1 participant