LoginSignup
0
0

More than 1 year has passed since last update.

制御構文 while [Ruby]

Posted at

while

いつもwhile文の利用の仕方を忘れるので、ここに記しておく。

while 条件式 do
  実行する処理1
  実行する処理2
    :
end

なぜ忘れるのかというと、whileの条件式がtrueの場合ループするのか、falseの場合ループするのか忘れてしまうからである。

そこで、英語の意味を思い出してみた。
(接)while SV:~~の限り、SVする。

これに準じて覚えると、条件式がtrueの限り、ブロック内の処理を繰り返す。
ということになる。Ruby便利〜

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0