Why Break/Continue activity not allow in While Loop?

Hello @Pablito @loginerror

Why Break/Continue activity not allow in While Loop?
Studio allow only these activity toFor each loop.
I Suppose Break/Continue activity should allow in all Loop activity i.e While/Do While/Foreach.

@lakshman @Lahiru.Fernando @Jan_Brian_Despi guys what you think?

4 Likes

Logically, it is correct :sweat_smile:

1 Like

@sandeep13

No idea bro :frowning:

Actually these things will work in other programming languages but in UIPath its not working. May be someone from UIPath has to tell this why its not working here.

2 Likes

@sandeep13

I just did some reading on this…

Apparently, what they say is that for While, Do while loops, we can easily specify the stopping condition through the loop condition itself. However, for the other loop For Each, it does not have a place to specify a stopping condition and will loop until the end of the list unless we break it. This is the reason break/ continue activities are there for For Each and not for While, do while…

The other reason why coding can do and why uipath does not allow is because the workflow design standards are much different than the coding standards… Hence, things we do here is little different than actual coding

5 Likes

Okay @Lahiru.Fernando

3 Likes

Hi @sandeep13!

As @Jan_Brian_Despi said it’s a logical matter.

Each type of loop in programming (While, Do While, For, For Each) has their own purpose and structure.

For and For Each have predefined how the iteration needs to flow and, when the continue method is triggered, the loop knows what to do next. However, While loops don’t have a predefined behavior, just a condition which indicates to continue (or stop) running the loop.

Regarding break method, While loops purpose is to run until a condition is met, so there shouldn’t be any reason to use a break method, you would just need to have a condition that meets your needs. In a For and For Each loop the problem is that there is no way to stop the loop until all the iterations finish. That’s why the break method was created, so we where able to prevent the loop to continue running when there is no need.

2 Likes

@nerlichman
Thank you for explaining .got it

2 Likes

Look what I found while looking components in the marketplace :joy:

2 Likes

modern problem required modern solutions :joy::joy:

1 Like