3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ruby 勉強メモ(条件分岐)

Posted at

概要

前回はプログラミングにおいて最も基本となる変数と関数について勉強した。今回は条件分岐でつかうif else文のメモを以下に記す。


if ~ then
   処理1
elsif ~ then
   処理2
else
   処理3

が基本的な形

サンプルプログラム

その年がオリンピックの開催年かどうか判定するプログラムをif elseで作成してみた


year = 2021

if year%4 == 0 then
  print("今年はオリンピック")
elsif year == 2021 then
  print("今年はオリンピック(コロナウイルスにより延長)")
else
  print("今年はオリンピックではない")
end

参考

3
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?