2 ms·
Rails does what he mentions ... [shell] ./script/console Loading development environment (Rails 2.3.3) >> nil.blank? => true >> "".blank? => true
by KevinMS 17y ago
Rails does what he mentions ...
[shell] ./script/console
Loading development environment (Rails 2.3.3)
>> nil.blank?
=> true
>> "".blank?
=> true
>> [].blank?
=> true
>> {}.blank?
=> true
It lets you write cleaner code in situations when you don't care if an object is empty data or a nil. Avoiding the "whiney nils" ruby has a reputation for.
instead of
if myobj && myobj.size == 0 then :blah end
you can write
if myobj.blank? then :blah end
makes me miss perl though