Just want to point out a great post by Joyce Echessa talking about the differences between all the nullish state methods for Ruby: Nil? Empty? Present? Blank?
#nil? | #empty? | #blank? | #present? | |
---|---|---|---|---|
5 | false | NoMethodError | false | true |
"" | false | true | true | false |
" " | false | false | true | false |
"\t\n" | false | false | true | false |
[] | false | true | true | false |
["a"] | false | false | false | true |
{} | false | true | true | false |
{a: "b"} | false | false | false | true |
Set.new | false | true | true | false |
nil | true | NoMethodError | true | false |
true | false | NoMethodError | false | true |
false | false | NoMethodError | true | false |
She goes into a deep dive of each in her post.
https://blog.appsignal.com/2018/09/11/differences-between-nil-empty-blank-and-present.html