-
[Ruby] break, nextcoding for food 2022. 7. 21. 13:50
# break - immediately exist the loop # next - skips to the next iteration i = 1 while 1 <= 10 puts i if i == 5 next end puts i i += 1 end puts "loop end"
# break - immediately exist the loop
# next - skips to the next iteration
i = 1
while 1 <= 10
puts i
if i == 5
next
end
puts i
i += 1
end
puts "loop end"