Do Rails docs have this information for Object#blank?
An object is empty if its false, empty or a string of spaces. For example, "," ", nil, [] and {} are empty.
But the source of this method is as follows:
# File activesupport/lib/active_support/core_ext/object/blank.rb, line 12 def blank? respond_to?(:empty?) ? empty? : !self end
Now when I open my handy little command line and type ruby -e 'p " ".empty?' , it returns false. This means that Rails has to say that this is an empty value when this is clearly not the case. But! I open my rails console and I type " ".empty? and get false as my earlier direct command line. But, I type ".blank?" and I believe how Rails promises me.
What am I missing in understanding how the Rails method is blank? works with the empty? method empty? for String?
jxpx777
source share