繰り返し
for i in 0..10 do #Cのfor. inでレンジを与える print "a" end print "\n" (0..10).each do |i| #レンジのメソッドで行うfor print 'b' end print "\n" i = 0 while i < 10 #Cのwhile. print i += 1 end print "\n" begin #Cのdo-while print i += 1 end while i < 20 print "\n"
while,forはdo,改行,';'で区切る
whileの逆(条件がfalseの時に継続する)のuntilがある
whileなどの内側から脱出するときは break
whileなどで次回のループに移行するときは next
whileなどで現在のループをやり直すときは redo