Ruby: Exit Loop
Exit Loop
next
→ start the next iteration.break
→ exit loop.
# ruby for xx in 1..9 do p xx if xx == 4 then break end end # prints 1 to 4
while-loop with break
:
# ruby ii = 1 while ii < 9 do puts ii; if ii == 5 then break end ii += 1 end # prints 1 to 5