반복문
while
while 조건
# write something
endwhile a < 5
puts a
a += 1
end
# 0
# 1
# 2
# 3
# 4until
until 조건
# write something
endfor
loop
Last updated
while 조건
# write something
endwhile a < 5
puts a
a += 1
end
# 0
# 1
# 2
# 3
# 4until 조건
# write something
endLast updated
a=0
#=> 0
until a == 5
puts a
a += 1
end
# 0
# 1
# 2
# 3
# 4for num in 1...10
puts num
endfor num in 1...3
puts num
end
# 1
# 2
#=> 1...3
for num in 1..3
puts num
end
# 1
# 2
#3
#=> 1..3i = 0
loop do
i += 1
print "#{i}"
break if i > 5
endfor i in 1..5
next if i % 2 == 0
print i
endfor i in 1..10
next if i % 2 ==0
puts i
end
# 1
# 3
# 5
# 7
# 9
# 1..10