0
0

More than 3 years have passed since last update.

||= とは?

Posted at

||= とは?

代入された値がnilだった場合右辺の値を代入する。

value3 = nil #nilを代入している。

value3 ||= 'りんご' #||=で'りんご'を代入

symbol3 = case value3
            when 'りんご','なし','きうい','もも'
                '果物'
            when 'きゃべつ', 'きゅうり', 'トマト'
                'やさい'
            when
                '該当なし'
            end

puts symbol3

戻り値
果物

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