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

returnとifの併用方法!

Posted at

未経験エンジニア転職を目指しているりんころです!
なんじゃこれと思ったので記事にしました!

returnとifの併用について

  def clean?(room)
    return nil if room.blank?
  end

これってなんぞやって思ったんですけど、

⭐️簡潔にいうと、if以降のコード「if room.blank?」がtrueの場合、nilを返しますよっていう意味です!

例えば、return以降に、コードがあった場合、nilが返されたら、

return以降は実行しないようにする際も使えます!

参考サイト

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?