LoginSignup
4
0

More than 3 years have passed since last update.

if else

Last updated at Posted at 2020-12-30

概要

Ruby における if else の使い方

簡単な説明

条件分岐を行いたい場合に、以下のようにして if else を用いる

if  [then]
 ...
[elsif  [then]
 ... ]
...
[else
 ... ]
endputs 'hello world'

if, elsif, および else を用いることで、条件分岐におけるバグを減らすことができる

うるう年かをスマートに判断するプログラム

year = 1999
if year %4 ==0 then
  return true
else
  return false
end

return year%4 == 0 ? true : false

  • source ~/grad_members_20f/members/FumiyaToyoda/if_else.org
4
0
1

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