Method: Object#blank?

Defined in:
lib/active_support/core_ext/object/blank.rb

#blank?true, false

An object is blank if it’s false, empty, or a whitespace string. For example, false, ”, ‘ ’, nil, [], and {} are all blank.

This simplifies

!address || address.empty?

to

address.blank?

Returns:

  • (true, false)


19
20
21
# File 'lib/active_support/core_ext/object/blank.rb', line 19

def blank?
  respond_to?(:empty?) ? !!empty? : !self
end