Wednesday, January 14, 2009

Rails nil, null empty or blank object

From the rails Ruby Object extenstion, The Object#blank? is now covering nil, blank and empty responses.

so:
elad = nil
elad.blank? # true
and even empty containers
elad = []
elad.blank? # true

note: Remember that this is a Rails extension to Ruby's Object, so it will not work on IRB, but will on console

No comments:

Post a Comment

Tell me what you think