false.blank? == true
seems correct for me.
In Ruby only false
and nil
evaluate false
in a conditional. Everything else evaluates to true
. These semantics are simple but sometimes you want different semantics. You want things like an empty string or an empty array to evaluate to false. Therefore as an extension Rails adds the concept of “blank” to includes other things. But the false
and nil
are also considered blank. The new items added are in addition to what is already considered false
. Some languages/libraries uses the term “falsey” as this sort of extended version of false.
value | Ruby | Rails |
---|---|---|
nil | false | blank |
false | false | blank |
[] |
true | blank |
'' |
true | blank |
NOTE: There are other things that can evaluate to blank besides just []
and ''
. Really anything that responds to empty?
is blank?
. I just used []
and ''
as to common examples of things that are blank.