1208748959*[ruby]ifについて実験する
公開日:
:
最終更新日:2014/02/04
未分類
if nil then …
>> if nil then puts true end
=> nil
>> unless nil then puts true end
true
=> nil
if 0 then …
>> if 0 then puts true end
true
=> nil
>> unless 0 then puts true end
=> nil
if “” then …
>> if "" then puts true end
(irb):52: warning: string literal in condition
true
=> nil
>> unless "" then puts true end
(irb):53: warning: string literal in condition
=> nil
if s then …
>> s = ""
=> ""
>> if s then puts true end
true
=> nil
>> unless s then puts true end
=> nil