I find myself repeatedly looking for a clear definition of the differences of nil?
, blank?
, and empty?
in Ruby on Rails. Here\'s the
Everybody else has explained well what is the difference.
I would like to add in Ruby On Rails, it is better to use obj.blank?
or obj.present?
instead of obj.nil?
or obj.empty?
.
obj.blank?
handles all types nil
, ''
, []
, {}
, and returns true
if values are not available and returns false
if values are available on any type of object.