Ruby on rails 你能想象一下你现在的样子吗?两个都换!图像。零?还有!图像。空白?
而不是使用:Ruby on rails 你能想象一下你现在的样子吗?两个都换!图像。零?还有!图像。空白?,ruby-on-rails,Ruby On Rails,而不是使用: !image.nil? and !image.blank? 我可以用image.present吗?要同时替换两个吗?是。。它在检查空数组时也很有用: [].present? == false 是否存在?: 和空白?: 因此: !图像。零?还有!image.blank?可以是:!图像。空白? !image.blank?是image.present? 因此,!图像。零?还有!image.blank?与image.present? # File activesupport/li
!image.nil? and !image.blank?
我可以用image.present吗?要同时替换两个吗?是。。它在检查空数组时也很有用:
[].present? == false
是否存在?
:
和空白?
:
因此:
可以是:!图像。零?还有!image.blank?
!图像。空白?
是!image.blank?
image.present?
!图像。零?还有!image.blank?
与image.present?
# File activesupport/lib/active_support/core_ext/object/blank.rb, line 22
def present?
!blank?
end
# File activesupport/lib/active_support/core_ext/object/blank.rb, line 15
def blank?
respond_to?(:empty?) ? !!empty? : !self
end