Skip to content

While Loop

The while loop also comes in four variations:

yuescript
i = 10
while i > 0
  print i
  i -= 1

while running == true do my_function!
yue
i = 10
while i > 0
  print i
  i -= 1

while running == true do my_function!
yuescript
i = 10
until i == 0
  print i
  i -= 1

until running == false do my_function!
yue
i = 10
until i == 0
  print i
  i -= 1
until running == false do my_function!

Like for loops, the while loop can also be used an expression. Additionally, for a function to return the accumulated value of a while loop, the statement must be explicitly returned.

Repeat Loop

The repeat loop comes from Lua:

yuescript
i = 10
repeat
  print i
  i -= 1
until i == 0
yue
i = 10
repeat
  print i
  i -= 1
until i == 0