coding for food

[Ruby] break, next

silveryen 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"
저작자표시 비영리 변경금지 (새창열림)