「Ruby/if」の版間の差分
提供: 初心者エンジニアの簡易メモ
(ページの作成:「 name = "taro" if name == "taro" then elsif name == "jiro" then elsif name == "saburo" then else end」) |
|||
| (同じ利用者による、間の1版が非表示) | |||
| 行5: | 行5: | ||
else | else | ||
end | end | ||
| + | |||
| + | ==nil判定== | ||
| + | if id.nil? then | ||
| + | |||
| + | ==一行if== | ||
| + | title = !@title.nil? ? 'titleあり' : 'titleなし' | ||
2017年11月17日 (金) 09:13時点における最新版
name = "taro" if name == "taro" then elsif name == "jiro" then elsif name == "saburo" then else end
nil判定
if id.nil? then
一行if
title = !@title.nil? ? 'titleあり' : 'titleなし'
