You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: