Rubyの条件式
条件分岐
最後に評価された式を戻り値として返す
if
code:if.rb
if 式 then
式 ...
[elsif 式 then
式 ... ]
...
[else
式 ... ]
end
code:if_modifier.rb
式 if 式 # if修飾子や後置ifと呼ばれる
Rubyは何故 if else ではなく if elsif なのか - 動かざることバグの如し
unless
code:unless.rb
unless 式 then
式 ...
[else
式 ... ]
end
code:unless_modifier.rb
式 unless 式 # unless修飾子や後置unlessと呼ばれる
case
code:case.rb
case 式
[when 式 式 ...`*' 式 then
式..]..
[when `*' 式 then
式..]..
[else
式..]
end
関連URL
Rubyのスタイルガイド
#Rubyを学ぶ