.nil? .empty? .blank? .present? 方法总结

###nil?

a=nil
a.nil? = true

a=""
a.nil = false

###empty?

"".empty?
=> true
" ".empty?
=> false

###blank?

nil.blank?
=>true
[].blank?
=> true
{}.blank?
=> true
"".blank?
=> true
"  ".blank?
=> true

###present? 这个就是blank?他的反义词

def present?
 !blank?
end

Comments