よくあるのは array, hash, string に empty? を使ったときに nil がくるから
if v.nil? || v.empty?
と書かないといけないのが面倒、というパターンだと思います。 そこで、ここでは Rails (actionsupport) の blank.rb を紹介します。
http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/core_ext/blank.rb これを使えば
if v.blank?
と書けてうれしい。
Posted on Monday January 18th