almost 2 years ago

[转]原帖:http://mayalin.logdown.com/posts/2016/09/08/rails-nil-empty-any-blank-present-the-difference

.blank?
• Rails method
• 用于任何object上,只要是nil或空值都是true。
• 相对的method是.present? !obj.blank? == obj.present?

nil.blank?     #true

[].blank?      #true

{}.blank?      #true

"".blank?      #true

" ".blank?     #true

"abc".blank?   #false

123.blank?     #false
← build是什么意思? 今日学习orid 20170209 →