-
Notifications
You must be signed in to change notification settings - Fork 0
Loops
Julius Paffrath edited this page Jul 2, 2026
·
3 revisions
jask provides three different ways to repeat code:
- while
- for in
- repeat times
A while-loop will repeat the code as long as a condition is true:
set i to 0
while i < 5
print(i)
set i to i + 1
endwhileUse for in if you need to iterate over a set of data stored in a list:
set myList to list(1, 2, 3)
for element in myList
print(element)
endforWith repeat times one can repeat a statement a predefined number of times (as the name suggests):
repeat task() 5 timesLoops can be controlled via continue and break. Continue will skip the rest of the current iteration while break stops the whole loop execution:
set i to 0
while true
if i == 50 continue endif ; skips the rest of the iteration
print(i)
if i == 100 break endif ; skips the entire loop
set i to i + 1
endwhile