Break a Loop (for each loop)


#1

How can I break a for each loop ?
image
I tried to set the value of number to 5 when the condition in if-else is meet but I get this error
image


#2

Currently, you can’t. However, MIT are working on adding a block for this.


#3

Okay thanks for the response :grinning:


#4

I don’t think you posted the blocks for this?

I also don’t think it’s a problem with the loop. Looks more like a problem with an image.


#5

ahh
yeah my bad, but anyway thank you :grinning:
I found an extension for this :grin:


#6

You can set a variable to true and when you have the break condition set it to false.
At the beginning of your loop, check that variable and if is false the loop do nothing. So the loop go trough anyway but doesn’t do elaboration.


#7

Okay I’ll try that
thanks for the idea:grinning: