Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is repeat until nil an infanite loop?

Asked by 10 years ago

Is repeat until nil an infanite loop?

1 answer

Log in to vote
3
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

Yes.


repeat loops work similarly to while loops, with two differences:

1) They only check the condition after running the first time (while loops act like if statements for the first time)

2) repeat loops stop on a truey value (until implies you are waiting for something) while while loops stop on a falsey value.

There are two "falsey" values: false and nil. All others are "truey".

So,

repeat until nil is the same as the perhaps more recognizable repeat until false

Since the condition nil (or false) is a constant and always falsey, it can never change to indicate the loop will stop. So the loop is infinite and will continue on until a break or return.

Ad

Answer this question