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, nil, ”, ‘ ’, [], {}, and false are all blank.

This simplifies

!address || address.empty?

to

address.blank?

Returns:

  • (true, false)


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

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