1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Ruby on Rails】nilチェックは「==」を使わずスマートに

Posted at

#人間はすぐに忘れるモノ...
はいだから書きます。
レビューで指摘していただいた10分後に書いています(笑)

いつもの癖ですぐに使ってしまう下記の様なコード。

if hoge == nil
  #処理があって
end

すぐに「==」演算子を仕様する癖が染み付いていますのでここで矯正。

if hoge.nil?
  #処理があって
end

以上です。これでもう同じことはしない。

1
0
1

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?