#02:条件によるくり返し処理1 - while
ここでは、条件に合わせてループ処理を実行します。そのために、while(ワイル)命令の使い方を学びます。
# whileによるループ処理
# カウンタ変数を初期化
while 条件式 do # doは省略可能
#繰り返し処理
#カウンタ変数を更新
end
このチャプターで作成した、Rubyのコードです。
# whileによるループ処理
i = 1 # カウンタ変数を初期化
while i <= 10 # 1 -> 2 -> 3 -> 4 ・・・ 10 -> 11
puts i # 繰り返し処理
i = i + 1 # カウンタ変数を更新
end
puts "last #{i}"
- while文 - 繰り返し - Ruby入門
https://www.javadrive.jp/ruby/for/index1.html
-【Ruby】繰り返し処理について(for, while, until, each, time, loop) - TASK NOTES
https://www.task-notes.com/entry/20141117/1416153598