LoginSignup
17
21

More than 5 years have passed since last update.

Railsでの変数初期化 nilガード

Posted at
a ||= []

aがnilなら[]を初期値として、nilでないならばaとする

いつかどこかで解説を見た気がしたけれど、"||="ではググれないのでメモ
いま解説をメタプログラミングRubyで見つけたので
次から忘れたら"nilガード"でググろう

17
21
2

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
17
21