Control Flow
Loop Control
Skip and stop loop iterations with next and break.
Source
control_flow/loop_control.vibe
def odds_below(limit)
out = []
n = 0
while n < limit
n = n + 1
if n == limit
break
end
if n % 2 == 0
next
end
out = out + [n]
end
out
end
def run
odds_below(10)
end
Output
Press Run example to run this code.