Help us understand the problem. What is going on with this article?

Ruby on Railsのtrue/false まとめ

More than 5 years have passed since last update.
xxx.nil? xxx.empty? xxx.blank? xxx.present? if xxx
nil True Error True False False
0 False Error False True True
1 False Error False True True
"" False True True False True
" " False False True False True
"word" False False False True True
[] False True True False True
[nil] False False False True True
[0] False False False True True
[""] False False False True True
[" "] False False False True True
["word"] False False False True True
{} False True True False True
{:ni => nil} False False False True True
{:ze => 0} False False False True True
{:bl => ""} False False False True True
{:sp => " "} False False False True True
{:wo => "word" False False False True True
nilかどうかだけ 入れ物の中身が入っているか入っていないか。スペースは""の中にスペースが入っているのでfalse。[nil][""]も、nilや空の文字列が入っているのでfalse。 nilかどうか(nil?)+空かどうか(empty?)+スペースだけかどうか 単純にblank?の反対。スペースはあるとはみなされない。 単純にnil?の反対。なにかしらの入力があればTRUE。
18sasaki
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした