News for hackers. Stuff that matters.
Re:True, False And Nil Objects In Ruby by KevinMS on Tuesday September 08, 2009 @12:47PM (#811344)
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

There are no comments on this comment yet.