Loop While
O loop while também vem em quatro variações:
i = 10while i > 0 print i i -= 1
while running == true do my_function!i = 10while i > 0 print i i -= 1
while running == true do my_function!i = 10until i == 0 print i i -= 1
until running == false do my_function!i = 10until i == 0 print i i -= 1until running == false do my_function!Como os loops for, o loop while também pode ser usado como expressão. Expressões while e until suportam break com múltiplos valores.
value, doubled = while true n = get_next! break n, n * 2 if n > 10value, doubled = while true n = get_next! break n, n * 2 if n > 10Além disso, para uma função retornar o valor acumulado de um loop while, a instrução deve ser explicitamente retornada.
Loop Repeat
Seção intitulada “Loop Repeat”O loop repeat vem do Lua:
i = 10repeat print i i -= 1until i == 0i = 10repeat print i i -= 1until i == 0Expressões repeat também suportam break com múltiplos valores:
i = 1value, scaled = repeat break i, i * 100 if i > 3 i += 1until falsei = 1value, scaled = repeat break i, i * 100 if i > 3 i += 1until false